Cannot drop the table <TableName> because it is being used for replication

Viewed 14889

I am unable to modify the structure of a table in a database. database used for replication. I am getting This error

enter image description here

2 Answers

I was having this error on my replication

Cannot drop the table 'dbo.repl_application_camp_choice' because it is being used for replication. (Source: MSSQLServer, Error number: 3724)

the first thing I tried - wrongly - is to manually drop the table in the subscriber db.

enter image description here

But the same error was there.

the next thing I tried is this:

USE [ORCASTG]
GO
EXEC sp_msunmarkreplinfo 'dbo.repl_application_camp_choice'

--Msg 3724, Level 16, State 3, Line 5
--Cannot drop the table 'dbo.repl_application_camp_choice' because it is being used for replication.

but it did not work

then I tried this one:

USE [ORCASTG]
GO
DECLARE @subscriptionDB AS sysname  
SET @subscriptionDB = N'ORCASTG'  

USE master  
EXEC sp_removedbreplication @subscriptionDB  
GO  

USE [ORCASTG]
GO
DROP TABLE IF EXISTS [dbo].[repl_application_camp_choice]
GO

and this did the trick

enter image description here

and after running the script above:

enter image description here


I also looked here and here and here.

Related