sp_reinitmergesubscription(Transact-SQL)

적용 대상:SQL Server

병합 에이전트가 실행되는 다음 번에 병합 구독이 다시 초기화되도록 표시합니다. 이 저장 프로시저는 게시 데이터베이스의 게시자에서 실행됩니다.

Transact-SQL 구문 표기 규칙

구문

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

인수

[ @publication = ] N'publication'

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

[ @subscriber = ] N'subscriber'

구독자의 이름입니다. @subscriber sysname이며 기본값은 .입니다all.

[ @subscriber_db = ] N'subscriber_db'

구독자 데이터베이스의 이름입니다. @subscriber_db sysname이며 기본값은 .입니다all.

[ @upload_first = ] N'upload_first'

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

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

반환 코드 값

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

설명

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

sp_reinitmergesubscription 병합 구독을 다시 초기화하기 위해 게시자에서 호출할 수 있습니다. 스냅샷 에이전트 다시 실행해야 합니다.

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

예제

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

USE [AdventureWorks2022Replica]

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

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

USE [AdventureWorks2022Replica]

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