We have Distributed AG across two windows clusters.

  • Clus01 - Has an AG set up with no DB inside it (AG1)
  • Clus02 - Has an AG set up with no DB inside it (AG2)
  • Clus01 - Has a DistAG set up with AG1 (primary) and AG2 (secondary)


  • Joined Clus02 to the DistAG
  • Added a database to AG1 on Clus01
  • Restored this DB in recovery to AG2
  • Added this DB to AG2 on Clus02 (Showing as Primary, but really is secondary within the DistAG)

DB on Clus02 was now working as expected...any updates on DB on Clus01 would use DistAG to update Clus02 DB.

We often refresh this environment from live (this is preprod). so we have to restore the DB onto CLus01.

For our normal AGs, we just remove the DB from CLUS01, restore to CLUS01, backup and restore to CLUS02 and join to AG again.

For DistAG, I cannot

  1. Remove the DB from AG2 on CLUS02.

    REMOVE DATABASE [Genesis];

    We get the error

    Msg 41190, Level 16, State 8, Line 6 Availability group 'AG2' failed to process remove-database command. The local availability replica is not in a state that could process the command. Verify that the availability group is online and that the local availability replica is the primary replica, then retry the command.

  2. Remove the DB from AG1 on CLUS01. DB on AG2 on CLUS02 goes into not syncronizing state and I cannot remove (same error as above), so cannot restore DB over the top.

  3. Remove the replica on the DistAG by running on CLUS01


    We get the error

    Msg 15151, Level 16, State 1, Line 5 Cannot alter the availability group 'AG2', because it does not exist or you do not have permission.

Is there anyone that knows how I can refresh an environment with DistAG without having to remove the whole DistAG and set it up again?

3 Answers 3


Is there anyone that knows how I can refresh an environment with DistAG without having to remove the whole DistAG and set it up again?

Removing and re-creating is going to be your best bet if this is done with many databases... though I'd argue the need for a database in a Distributed Availaiblity Group which needs to be refreshed each day.

The only other option is to fail the Distributed Availability Group over after removing the database from the global primary so that the forwarder becomes the new global primary. Then you will be able to remove the database from the (now primary) second availability group. That's less appealing of an approach due to the connections being killed, versus the remove + add approach you already have which will keep connections to the current global primary.

You can always remove the database from the forwarder or a secondary on the forwarder side with ALTER DATABASE [name] SET HADR OFF


You can use the below statement to remove the database from "DistAG".

Execute the below statement on primary node of "DistAG".


Once you execute the above statement, the database state will turn to restoring mode, and then you can drop the database.

  • This works as I've just had to do it Commented Jul 13, 2022 at 9:58

The correct way to remove a DB that is part of a DistAG is detailed SQL - Delete a Database in a Distributed Availability Group.

Correct way to remove a database from a Distributed Availability Group

  1. Turn HADR off on forwarder on secondary AG

From forwarder server at secondary AG run the following command setting your database name

USE master


Once this has ran it breaks the Distributed AG replication for the database

  1. Remove DB from Primary AG

On the primary server of the primary AG, remove the database from the AG

  • Primary server will go back to a normal un-replicated database
  • Primary replica will go into a restoring state
  1. Remove it from each AG starting on secondary AG replica in the following order;
  • Replica on secondary AG
  • Forwarder on secondary AG
  • Replica on primary AG
  • Primary on primary AG

The database should now be successfully removed from all locations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.