我有一个使用合并复制同步的Publisher服务器和订阅服务器。当我使用向导删除复制时,登录窗口要求我登录Subscriber Server并删除其订阅,但是当我使用生成的脚本删除复制时,订阅者中的订阅将不会删除。我怎样才能使用TSQL? 换句话说: 我想使用T-SQL
连接到订阅者并删除订阅者的订阅记录答案 0 :(得分:1)
要删除合并推送订阅,您必须连接到发布服务器和订阅服务器。每How to: Delete a Push Subscription (Replication Transact-SQL Programming) - 在发布商处执行sp_dropmergesubscription,在订阅者处执行sp_mergesubscription_cleanup。
答案 1 :(得分:1)
最后我找到了解决问题的方法:
我使用Linked 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'