Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»SQL Server»(Fixed) Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724)

    (Fixed) Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724)

    By RahulJune 23, 20211 Min Read

    Error:

    Sometimes I face issues with the database deletion in the SQL server. If we have configured replication in the database previously. In that case, when I try to remove the database it gives me the following error.

    Advertisement

    Cannot drop the database ‘Test_db’ because it is being used for replication. (Microsoft SQL Server, Error: 3724)

    Solution 1:

    Use the sp_removedbreplication stored procedure to remove all the replication objects on the publication and subscription databases.

    Make sure to change the database name “Test_db” with your database name.

    DECLARE @subscriptionDB AS sysname  
    SET @subscriptionDB = N'Test_db'  
    
    USE master  
    EXEC sp_removedbreplication @subscriptionDB  
    GO  
    

    After executing the above T-SQL statement, you can remove your database.

    Solution 2:

    Create a database with the same name on another SQL server instance. Then create a full backup of the database. Now restore the database to this server forcefully.

    To restore the database forcefully, make sure to select the “WITH REPLACE” option

    Restore Database in SQL Server with SSMS

    Now you can remove the database from the SQL Server.

    SQL SErver T-SQL
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Backup SQL Server Database

    How to Backup SQL Server Database

    How to Restore SQL Server database

    How To Restore SQL Server Database

    How to Rename SQL Server Database

    How to Rename a SQL Server Database

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.