Search code examples
sql-servertransactional-replication

Why am I getting the error "Cannot drop the database 'test' because it is being used for replication. Error: 3724"?


I deleted all the publications and subscriptions related to the database 'test'. All I have now are the publications and subscriptions related to other databases in the server. Still, It says "Cannot drop the database 'test' because it is being used for replication."

For evidence, These are the current publications related to another database "Computers": enter image description here


Solution

  • The message stating "Cannot drop the database 'test' because it is being used for replication." is due to because the database is still marked as a publisher.

    select * from sys.databases where is_published = 1
    

    Once you remove all the publications, can you unmark the database as the publisher with

    EXEC sp_removedbreplication 'DB_Name'
    

    https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-removedbreplication-transact-sql?view=sql-server-ver15