Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

generate sp_dropsubscription statements to drop many but not all

$
0
0

Hello,

I have been asked to update 60 articles (tables) that are in replication so I want to generate a script that automatically gets the articles and plugs them into an sp_dropsubscription statement so that I can run all 60 rather than unchecking the 60 boxes in SSMS.  I would like to add them back in via a script as well.

Here's a rough version of what I have been trying to do:

select "sp_dropsubscription ''my publication nameHardCoded'', ''" || article ||"'', ''myPublisherHardcoded'', ''myPubDBhardcoded''"

from MSpublications pub
inner join MSsubscriptions sub
	on pub.publication_id = sub.publication_id
inner join MSarticles art
	on sub.article_id = art.article_id
where article like 'Specimen_%'
and subscriber_db like 'mySubscriberDBhardcoded'


Is this a decent approach or is there a better (safer) way?  If this ok, do you know why I am getting a syntax error objecting to the concatenation bars.  Says:

.Net SqlClient Data Provider: Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '|'.  

Thanks!


Viewing all articles
Browse latest Browse all 4054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>