SQL Server Admin is not my forte. So please bear with while I explain this
A SQL Server 2012 cluster
is involved in a Change data capture ( CDC )
effort using a 3rd party CDC
utility. for it to work replication needs to be turned on, without replication CDC
will not work. The CDC
taps some 2000+ odd tables from SQL Server
in a database Db1. Out of these we found out that some 200+ tables undergo truncate
and load
as against increments. So we removed those from our CDC lists but since replication is turned on at DB Level we also need to remove these from publication database
so that truncates happening to this exception list wont need replication
switched off DB level ( aka truncates to these tables and replication
can co-exist. As its known, for truncates to happen we need to switch off replication. The code is in prod so replacing truncate
by delete
is not an option now besides the fact that for billion row tables deletes are going to be expensive & time consuming )
The above is the requirement. So based on that if a better solution can be conceived do let me know
What I tried :
EXEC sys.sp_droparticle @publication = 'pub', @article = 'art', @force_invalidate_snapshot = 1
Error I get
Msg 14013, Level 16, State 1, Procedure sp_MSrepl_droparticle, Line 104 [Batch Start Line 2]
This database is not enabled for publication.
Another SP
DECLARE @subscriber AS sysname;
EXEC sp_dropsubscription @publication = 'AR_PUBLICATION_00010', @article = 'BPA_BRGR_RUL_GRP_R' ,@subscriber=@subscriber
Msg 14013, Level 16, State 1, Procedure sp_MSrepl_dropsubscription, Line 55 [Batch Start Line 1]
This database is not enabled for publication.
But using GUI
I am able to uncheck the tables I dont want in that publication
. ( right click publication --> properties --> articles --> check /uncheck whatever you want excluded ) . I dont have any subscription
just there is a publication.
Whatever code I ran through GUI above I can def. run through T-SQL But I dont know what code was it that was run ? How do I get this done using a scripting approach. I have 200+ tables to deal with and unchecking em 1 by 1 ain't helping
Nearly four years late, but in case it helps anyone... I think you want sp_dropmergearticle
not sp_droparticle
.
EXEC sys.sp_dropmergearticle @publication = 'pub', @article = 'art', @force_invalidate_snapshot = 1
I was getting an identical error message using sp_droparticle
, but sp_dropmergearticle
removed the table from the publication and allowed me to delete it.