sp_addmergepullsubscription(Transact-SQL)

병합 게시에 끌어오기 구독을 추가합니다. 이 저장 프로시저는 구독 데이터베이스의 구독자에서 실행됩니다.

항목 링크 아이콘 Transact-SQL 구문 표기 규칙

구문

sp_addmergepullsubscription [ @publication= ] 'publication' 
    [ , [ @publisher= ] 'publisher' ] 
    [ , [ @publisher_db = ] 'publisher_db' ] 
    [ , [ @subscriber_type= ] 'subscriber_type' ] 
    [ , [ @subscription_priority= ] subscription_priority ] 
    [ , [ @sync_type= ] 'sync_type' ] 
    [ , [ @description= ] 'description' ]

인수

  • [ @publication=] 'publication'
    게시의 이름입니다. publication은 sysname이며 기본값은 없습니다.

  • [ @publisher=] 'publisher'
    게시자의 이름입니다. Publisher는 sysname이며 기본값은 로컬 서버 이름입니다. 게시자는 유효한 서버여야 합니다.

  • [ @publisher_db =] 'publisher_db'
    게시자 데이터베이스의 이름입니다. publisher_db는 sysname이며 기본값은 NULL입니다.

  • [ @subscriber_type=] 'subscriber_type'
    구독자의 유형입니다. subscriber_type은 nvarchar(15)이며 global, local 또는 anonymous가 될 수 있습니다. SQL Server 2005 이상 버전에서 로컬 구독은 클라이언트 구독이라고 하며 전역 구독은 서버 구독이라고 합니다.

  • [ @subscription_priority=] subscription_priority
    구독 우선 순위입니다. subscription_priority는 real이며 기본값은 NULL입니다. 로컬 및 익명 구독의 경우에는 우선 순위가 0.0입니다. 우선 순위는 기본 해결 프로그램이 충돌을 감지했을 때 적용되는 내용을 선택하는 데 사용합니다. 전역 구독자인 경우 구독 우선 순위는 100 미만이어야 합니다. 100은 게시자의 우선 순위입니다.

  • [ @sync_type=] 'sync_type'
    구독 동기화 유형입니다. sync_type은 nvarchar(15)이며 기본값은 automatic입니다. automatic 또는 none이 될 수 있습니다. automatic인 경우 게시된 테이블의 스키마 및 초기 데이터가 구독자에게 먼저 전송됩니다. none인 경우 구독자에 게시된 테이블의 스키마 및 초기 데이터를 이미 있다고 가정합니다. 시스템 테이블 및 데이터는 항상 전송됩니다.

    [!참고]

    none 값은 지정하지 않는 것이 좋습니다.

  • [ @description=] 'description'
    해당 끌어오기 구독에 대한 간단한 설명입니다. description은 nvarchar(255)이며 기본값은 NULL입니다. 이 값은 복제 모니터에서 이름 열에 표시되며 모니터링되는 게시에 대한 구독을 정렬하는 데 사용할 수 있습니다.

반환 코드 값

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

주의

sp_addmergepullsubscription은 병합 복제에 사용됩니다.

SQL Server 에이전트를 사용하여 구독을 동기화하는 경우 sp_addmergepullsubscription_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".

-- Execute this batch at the Subscriber.
DECLARE @publication AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publicationDB AS sysname;
DECLARE @hostname AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @publisher = $(PubServer);
SET @publicationDB = N'AdventureWorks2012';
SET @hostname = N'adventure-works\david8';

-- At the subscription database, create a pull subscription 
-- to a merge publication.
USE [AdventureWorks2012Replica]
EXEC sp_addmergepullsubscription 
  @publisher = @publisher, 
  @publication = @publication, 
  @publisher_db = @publicationDB;

-- Add an agent job to synchronize the pull subscription. 
EXEC sp_addmergepullsubscription_agent 
  @publisher = @publisher, 
  @publisher_db = @publicationDB, 
  @publication = @publication, 
  @distributor = @publisher, 
  @job_login = $(Login), 
  @job_password = $(Password),
  @hostname = @hostname;
GO

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

-- Publication must support anonymous Subscribers.
-- Execute this batch at the Subscriber.
DECLARE @publication AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publicationDB AS sysname;
DECLARE @websyncurl AS sysname;
DECLARE @security_mode AS int;
DECLARE @login AS sysname;
DECLARE @password AS nvarchar(512);
SET @publication = N'AdvWorksSalesOrdersMergeWebSync';
SET @publisher = $(PubServer);
SET @publicationDB = N'AdventureWorks2012';
SET @websyncurl = 'https://' + $(WebServer) + '/WebSync';
SET @security_mode = 0; -- Basic Authentication for IIS
SET @login = $(Login);
SET @password = $(Password);

-- At the subscription database, create a pull subscription 
-- to a merge publication.
USE [AdventureWorks2012Replica]
EXEC sp_addmergepullsubscription 
    @publisher = @publisher, 
    @publication = @publication, 
    @publisher_db = @publicationDB,
    @subscriber_type = N'anonymous';

-- Add an agent job to synchronize the pull subscription. 
EXEC sp_addmergepullsubscription_agent 
    @publisher = @publisher, 
    @publisher_db = @publicationDB, 
    @publication = @publication, 
    @distributor = @publisher, 
    @job_login = @login, 
    @job_password = @password,
    @use_web_sync = 1,
    @internet_security_mode = @security_mode,
    @internet_url = @websyncurl,
    @internet_login = @login,
    @internet_password = @password;
GO

사용 권한

sysadmin 고정 서버 역할의 멤버 또는 db_owner 고정 데이터베이스 역할의 멤버만 sp_addmergepullsubscription_agent를 실행할 수 있습니다.

참고 항목

참조

sp_addmergepullsubscription_agent(Transact-SQL)

sp_changemergepullsubscription(Transact-SQL)

sp_dropmergepullsubscription(Transact-SQL)

sp_helpmergepullsubscription(Transact-SQL)

sp_helpsubscription_properties(Transact-SQL)

개념

끌어오기 구독 만들기

게시 구독