Rahman Agoro, the frontline SQL DBA

Just another WordPress.com weblog

Cannot drop database XXXX because it is being used for replication.

Posted by rahmanagoro on March 15, 2016


If you have ever come across this error, its because replication has been setup on the database before and it needs to be removed before the database can be dropped.

In my case, I had the error when I tried to run the code below.

drop database TEST_FWXXX

Server: Msg 3724, Level 16, State 3, Line 1
Cannot drop the database XXX because it is being used for replication.

 

Please note that in this case, the publication and subscription had already been dropped. Simple to resolve, just remove the replication property on the DB by running the code below.

exec sp_removedbreplication ‘TEST_FWXXX’

After running this, I was then able to drop the database successfully.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: