sp_reinitmergepullsubscription(Transact-SQL)

적용 대상:SQL Server

다음에 병합 에이전트 실행할 때 다시 초기화할 병합 끌어오기 구독을 표시합니다. 이 저장 프로시저는 구독 데이터베이스의 구독자에서 실행됩니다.

Transact-SQL 구문 표기 규칙

구문

sp_reinitmergepullsubscription
    [ [ @publisher = ] N'publisher' ]
    [ , [ @publisher_db = ] N'publisher_db' ]
    [ , [ @publication = ] N'publication' ]
    [ , [ @upload_first = ] N'upload_first' ]
[ ; ]

인수

[ @publisher = ] N'publisher'

게시자의 이름입니다. @publisher sysname이며 기본값은 .입니다all.

[ @publisher_db = ] N'publisher_db'

게시자 데이터베이스의 이름입니다. @publisher_db sysname이며 기본값은 .입니다all.

[ @publication = ] N'publication'

게시의 이름입니다. @publication sysname이며 기본값은 .입니다all.

[ @upload_first = ] N'upload_first'

구독을 다시 초기화하기 전에 구독자의 변경 내용을 업로드할지 여부를 지정합니다. @upload_first 기본값false인 nvarchar(5)입니다.

  • 이 경우 true구독을 다시 초기화하기 전에 변경 내용이 업로드됩니다.
  • 이 경우 false변경 내용이 업로드되지 않습니다.

반환 코드 값

0 (성공) 또는 1 (실패).

설명

sp_reinitmergepullsubscription는 병합 복제본(replica)에 사용됩니다.

매개 변수가 있는 필터를 추가, 삭제 또는 변경하는 경우 구독자에서 보류 중인 변경 내용을 다시 초기화하는 동안 게시자에 업로드할 수 없습니다. 보류 중인 변경 내용을 업로드하려면 필터를 변경하기 전에 모든 구독을 동기화하세요.

예제

A. 끌어오기 구독을 다시 초기화하고 보류 중인 변경 내용 손실

-- 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'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2022Replica]

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

B. 끌어오기 구독 다시 초기화 및 보류 중인 변경 내용 업로드

-- 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'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2022Replica]

-- 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수 있습니다.