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

USE [AdventureWorks2012Replica]

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

USE [AdventureWorks2012Replica]

-- 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을 실행할 수 있습니다.

참고 항목

참조

시스템 저장 프로시저(Transact-SQL)

개념

구독 다시 초기화