Question

I have a Publisher server and Subscriber Server which are synchronized using Merge replication. When i using wizard to remove Replication a login window ask me to login on Subscriber Server and remove its subscription but when I using generated script for removing Replication, the subscription in subscriber won't remove. How can I do it using TSQL? In Other Word: I want to Connect to subscriber and delete record of subscription at subscriber also using T-SQL

Was it helpful?

Solution 2

At last I found the solution of my problem:

I used Linked Server to create a connection to remote server:

exec sp_addlinkedserver 'RemoteServer\PeerInstance', N'SQL Server'

exec sp_addlinkedsrvlogin 'RemoteServer\PeerInstant', 'true', 'sa', 'password'

exec ReplicatedDBOnMainServer.sys.sp_dropmergesubscription
@publication = N'PublicationName', 
@subscriber = N'RemoteServer\PeerInstant'

exec [RemoteServer\PeerInstant].ReplicatedDBOnRemote.sys.sp_mergesubscription_cleanup
@publisher = N'MainServer\MainInstant', 
@publisher_db = N'ReplicatedDBOnMainServer'
@publication = N'PublicationName'

OTHER TIPS

To drop a Merge push subscription you must to connect to both the Publisher and Subscriber. Per How to: Delete a Push Subscription (Replication Transact-SQL Programming) - execute sp_dropmergesubscription at the Publisher and sp_mergesubscription_cleanup at the Subscriber.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top