Quantcast
Channel: SQL Server High Availability and Disaster Recovery forum
Viewing all articles
Browse latest Browse all 4689

Use SMO (C#) to Drop a DB Joined to an Availability Group

$
0
0

I am having a heck of a time using SMO in C# to drop a database that is joined to an Availability Group. This is currently being done using dynamic SQL and we do the following...

for each secondary

  ALTER DATABASE db SET HADR OFF

  DROP db

on primary

  ALTER AVAILABILITY GROUP ag REMOVE DATABASE db

  DROP db

I am trying to replicate this behavior in SMO, but nothing seems to work. I've tried every combination of SuspendDataMovement, LeaveAvailabilityGroup and Drop that I can think of, and each time I just get back a FailedOperationException that says that the operation failed, but does not provide any more information. Does anyone have any experience using SMO to drop a database that is joined to Availability Group, and, if so, can they please share it with me?



Viewing all articles
Browse latest Browse all 4689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>