Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (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.

    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

    PowerShell Script to Backup SQL Server Databases

    How to Backup SQL Server Database

    How to Backup SQL Server Database

    How to Restore SQL Server database

    How To Restore SQL Server Database

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Difference Between Full Virtualization vs Paravirtualization
    • Virtualization vs. Containerization: A Comparative Analysis
    • Using .env Files in Django
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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