共用方式為


sp_reinitmergesubscription (Transact-SQL)

將合併訂閱標示為在下次執行合併代理程式時重新初始化。這個預存程序執行於發行集資料庫的發行者端。

主題連結圖示Transact-SQL 語法慣例

語法

sp_reinitmergesubscription [ [ @publication = ] 'publication'
    [ , [ @subscriber = ] 'subscriber'
    [ , [ @subscriber_db = ] 'subscriber_db'
    [ , [ @upload_first = ] 'upload_first'

引數

  • [@publication = ] 'publication'
    這是發行集的名稱。publication 是 sysname,預設值是 all

  • [@subscriber = ] 'subscriber'
    這是訂閱者的名稱。subscriber 是 sysname,預設值是 all

  • [@subscriber_db = ] 'subscriber_db'
    這是訂閱者資料庫的名稱。subscriber_db 是 sysname,預設值是 all

  • [@upload_first = ] 'upload_first'
    這是指在訂閱重新初始化之前,是否上載在訂閱者端的變更。upload_first 是 nvarchar(5),預設值是 FALSE。如果是 true,便會在訂閱重新初始化之前上載變更。如果是 false,就不會上載變更。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_reinitmergesubscription 用於合併式複寫中。

您可以從發行者呼叫 sp_reinitmergesubscription 來重新初始化合併訂閱。我們建議您也要重新執行快照集代理程式。

如果您新增、卸除或變更參數化篩選,在重新初始化期間,便無法將訂閱者的暫止變更上載到發行者。如果您要上載暫止變更,請在變更篩選之前,同步處理所有訂閱。

範例

-- 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 @subscriptionDB AS sysname;
DECLARE @publication AS sysname;
SET @subscriptionDB = N'AdventureWorks2008R2Replica';
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2008R2Replica]

-- Execute at the Publisher to reinitialize the push subscription. 
-- Pending changes at the Subscrber are lost.
EXEC sp_reinitmergesubscription 
    @subscriber = $(SubServer),
    @subscriber_db = @subscriptionDB,
    @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 @subscriptionDB AS sysname;
DECLARE @publication AS sysname;
SET @subscriptionDB = N'AdventureWorks2008R2Replica';
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2008R2Replica]

-- Execute at the Publisher to reinitialize the push subscription, 
-- and upload pending changes at the Subscriber. 
EXEC sp_reinitmergesubscription 
    @subscriber = $(SubServer),
    @subscriber_db = @subscriptionDB,
    @publication = @publication,
    @upload_first = N'true';
GO

-- Start the Merge Agent.

權限

只有系統管理員 (sysadmin) 固定伺服器角色或 db_owner 固定資料庫角色的成員,才能夠執行 sp_reinitmergesubscription