Sql-server – How to completely get rid of replication subscriptions

sql servertransactional-replication

I have restored a database in another server. I don't want any of the transactional subscriptions of the former database. I already called

exec sp_removedbreplication 'MyRestoredDB' 

And also

exec sp_cleanupdbreplication


exec sp_replicationdboption 'MyRestoredDB','Publish','False',1

But when I try

truncate table dbo.sample

I get the following error:

Msg 4711, Level 16, State 1, Line 7 Cannot truncate table 'sample'
because it is published for replication or enabled for Change Data

I verified that the database isn't enabled for CDC. What else I can do to perform the truncate? Delete isn't an option for reasons not relevant to the question.

Best Answer

Take a look at this article: https://www.mssqltips.com/sqlservertip/2710/steps-to-clean-up-orphaned-replication-settings-in-sql-server/

Try dropping the old subscriptions, all publications and then removing replication from the DB, i.e.

exec sp_dropsubscription --on all subscriptions


exec sp_droppublication --on all publications


exec sp_replicationdboption

Also, take a look at this question: How to fix a messed up replication on MS SQL Server