Share via


sp_reinitmergepullsubscription (Transact-SQL)

マージ エージェントの次回実行時に再初期化するように、マージ プル サブスクリプションにマークを付けます。 このストアド プロシージャは、サブスクライバー側でサブスクリプション データベースについて実行されます。

トピック リンク アイコン 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'AdventureWorks2012';
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2012Replica]

-- 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'AdventureWorks2012';
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2012Replica]

-- 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.

権限

sp_reinitmergepullsubscription を実行できるのは、固定サーバー ロール sysadmin または固定データベース ロール db_owner のメンバーだけです。

関連項目

参照

システム ストアド プロシージャ (Transact-SQL)

概念

サブスクリプションの再初期化

サブスクリプションの再初期化