Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to run the below code. It works for me but not for at least some of my users it doesn't work. It doesn't seem to error just no actually remove the DB's.

string sqlConnectionString=@"Data Source=.\SQLEXPRESS;Initial Catalog=master;Integrated Security=True";
var theSQL="DROP DATABASE DBName1, DBName2, DBName3, DBName4";
SqlConnection conn=new SqlConnection(sqlConnectionString);
Server server=new Server(new ServerConnection(conn));


Alternatively, what I really need is to remove the existing Replication Sets on those DB's so that I can setup the new ones. We moved to a new SQL Server but the database names are the same.

The subscription could not be initialized using an initial snapshot because one or more tables in the subscription belong to another publication, and therefore cannot be dropped. Consider initializing the subscription manually without using a snapshot.

Error they receive, though this would be after the above was supposed to run as this is during the Sync that happens next.

share|improve this question
Could you define "doesn't work?" Post the actual error they receive. It could be lack of permissions. There could be an active connection to the database. – billinkc Aug 20 '12 at 0:39
thanks, added the exception though I noted this is after the scripts. – Refracted Paladin Aug 20 '12 at 1:10

Depending on whether or not these are subscriptions or the published database you are going to need to drop the replication data.

MS Published a handy doc with example scripts here

This one is a general tool to clear out what you need

sp_removedbreplication '<Database name>'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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