sp_reinitmergepullsubscription (Transact-SQL)
將合併提取訂閱標示為在下次執行合併代理程式時重新初始化。這個預存程序執行於訂閱資料庫的訂閱者端。
語法
sp_reinitmergepullsubscription [ [ @publisher = ] 'publisher' ]
[ , [ @publisher_db = ] 'publisher_db' ]
[ , [ @publication = ] 'publication' ]
[ , [ @upload_first = ] 'upload_first'
引數
[@publisher = ] 'publisher'
這是發行者的名稱。publisher 是 sysname,預設值是 ALL。[@publisher_db = ] 'publisher_db'
這是發行者資料庫的名稱。publisher_db 是 sysname,預設值是 ALL。[@publication = ] 'publication'
這是發行集的名稱。publication 是 sysname,預設值是 ALL。[@upload_first = ] 'upload_first'
這是指在訂閱重新初始化之前,是否上載在訂閱者端的變更。upload_first 是 nvarchar(5),預設值是 FALSE。如果是 true,便會在訂閱重新初始化之前上載變更。如果是 false,就不會上載變更。
傳回碼值
0 (成功) 或 1 (失敗)
備註
sp_reinitmergepullsubscription 用於合併式複寫中。
如果您新增、卸除或變更參數化篩選,在重新初始化期間,便無法將訂閱者的暫止變更上載到發行者。如果您要上載暫止變更,請在變更篩選之前,同步處理所有訂閱。
範例
-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables
-- on the command line and in SQL Server Management Studio, see the
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".
DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
SET @publicationDB = N'AdventureWorks';
SET @publication = N'AdvWorksSalesOrdersMerge';
USE [AdventureWorksReplica]
-- Execute at the Subscriber to reinitialize the pull subscription.
-- Pending changes at the Subscrber are lost.
EXEC sp_reinitmergepullsubscription
@publisher = $(PubServer),
@publisher_db = @publicationDB,
@publication = @publication,
@upload_first = N'false';
GO
-- Start the Merge Agent.
-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables
-- on the command line and in SQL Server Management Studio, see the
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".
DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
SET @publicationDB = N'AdventureWorks';
SET @publication = N'AdvWorksSalesOrdersMerge';
USE [AdventureWorksReplica]
-- Execute at the Subscriber to reinitialize the pull subscription,
-- and upload pending changes at the Subscriber.
EXEC sp_reinitmergepullsubscription
@publisher = $(PubServer),
@publisher_db = @publicationDB,
@publication = @publication,
@upload_first = N'true';
GO
-- Start the Merge Agent.
權限
只有系統管理員 (sysadmin) 固定伺服器角色或 db_owner 固定資料庫角色的成員,才能夠執行 sp_reinitmergepullsubscription。