Share via


sp_reinitpullsubscription (Transact-SQL)

適用対象: SQL ServerAzure SQL Managed Instance

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

Transact-SQL 構文表記規則

構文

  
sp_reinitpullsubscription [ @publisher = ] 'publisher'  
        , [ @publisher_db = ] 'publisher_db'  
        , [ @publication = ] 'publication'  

引数

[ @publisher = ] 'publisher' パブリッシャーの名前を指定します。 publishersysname で、既定値はありません。

[ @publisher_db = ] 'publisher_db' パブリッシャー データベースの名前を指定します。 publisher_dbは sysname で、既定値はありません。

[ @publication = ] 'publication' パブリケーションの名前を指定します。 publicationsysname で、既定値は all で、すべてのサブスクリプションに再初期化をマークします。

リターン コードの値

0 (成功) または 1 (失敗)

解説

sp_reinitpullsubscriptionはトランザクション レプリケーションで使用されます。

sp_reinitpullsubscriptionは、ピアツーピア トランザクション レプリケーションではサポートされていません。

sp_reinitpullsubscriptionサブスクライバーから呼び出して、ディストリビューション エージェントの次の実行時にサブスクリプションを再初期化できます。

@immediate_syncの値が falseパブリケーションに対するサブスクリプションは、サブスクライバーから再初期化できません。

プル サブスクリプションを再初期化するには、サブスクライバーでsp_reinitpullsubscription実行するか、パブリッシャーでsp_reinitsubscriptionします。

-- 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'AdventureWorks2022';
SET @publication = N'AdvWorksProductTran';

USE [AdventureWorks2022Replica]

-- Execute at the Subscriber to reinitialize the pull subscription. 
EXEC sp_reinitpullsubscription 
    @publisher = $(PubServer),
    @publisher_db = @publicationDB,
    @publication = @publication;
GO

-- Start the Distribution Agent.

アクセス許可

sysadmin 固定サーバー ロールまたは固定データベース ロールdb_ownerメンバーのみが、sp_reinitpullsubscriptionを実行できます。

参照

サブスクリプションの再初期化
サブスクリプションの再初期化
システム ストアド プロシージャ (Transact-SQL)