September 10, 2013 at 5:17 pm
we are trying to target the re-initialization of a subscription at certain subscribers at the same time.
the following has been successful for a single subscriber:
sp_reinitsubscription @publication = 'my_publication',
@subscriber = 'subscriber1', @destination_db = 'dest_dbase',
@invalidate_snapshot = 1
substituting 'all' works for all the subscribers:
sp_reinitsubscription @publication = 'my_publication',
@subscriber = 'all', @destination_db = 'dest_dbase',
@invalidate_snapshot = 1
is there a syntax that allows for specifying multiple subscriptions but not all - say defining 10 subscriptions out of 20?
any help would be appreciated.
September 11, 2013 at 2:45 am
Hi,
Depending on your criteria you could do something like:
DECLARE@sql Varchar(MAX)
SELECT@sql = ''
--SELECTP.Name PubName, S.SrvName SubScriber, S.Dest_DB
'sp_reinitsubscription @publication = '''+P.Name+
''', @subscriber = '''+S.SrvName+
''', @destination_db = '''+S.Dest_DB+
''', @invalidate_snapshot = 1' + CHAR(13)
FROM[DBO].[sysPublications] P
INNER JOIN [DBO].[sysArticles] A ON P.PubID = A.PubID
INNER JOIN [DBO].[sysSubscriptions] S ON A.ArtID = S.ArtID
WHERES.SrvName <> ''
AND S.SrvName NOT IN ('List', 'of', 'subscribers', 'to', 'filter', 'out')
GROUPBY P.Name, S.SrvName, S.Dest_DB
PRINT @sql
--EXEC (@SQL)
Better yet, create a table of subscriber servers you wish to reinitiate and join to it instead of using IN ('blah', 'blah')
If more complex requirements are needed, alter the statement to use in a cursor.
Hope this helps.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply