sp_addmergepullsubscription (języka Transact-SQL)

Dodajesubskrypcja ściągaćdo publikacjakorespondencji seryjnej. Ta procedura składowana jest wykonywany przez subskrybenta bazy danych subskrypcja .

Ikona łącza do tematuJęzyka Transact-SQL składni konwencje

Składnia

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

Argumenty

  • [ @publikacja =] 'publication'
    Jest to nazwa publikacja.publicationjest sysname, z braku domyślne.

  • [ @ publisher =] 'publisher'
    Jest to nazwa Wydawca.Publisherjest sysname, domyślnie lokalna nazwa serwera.Wydawca musi być prawidłowy serwer.

  • [ @ publisher_db =] 'publisher_db'
    Jest to nazwa bazy danych Wydawca .publisher_dbjest sysname, domyślna wartość NULL.

  • [ @ subscriber_type =] 'subscriber_type'
    Jest to typ subskrybenta.subscriber_typejest nvarchar(15)i może być globalne, lokalne lub anonimowe.W SQL Server 2005 i jego nowsze wersje lokalne subskrypcje są nazywane subskrypcji klient i subskrypcje globalne są określane jako serwera subskrypcji.Aby uzyskać więcej informacji zobacz "Rodzaje subskrypcji" sekcja w Jak replikacji scalania wykrywa i usuwa konflikty.

  • [ @ subscription_priority =] subscription_priority
    Jest priorytet subskrypcja .subscription_priorityjest real, domyślna wartość NULL.Lokalne i anonimowe subskrypcji jest priorytet 0.0.Priorytet jest używany przez domyślny program rozpoznawania nazw do pobrania zwycięzcy podczas wykrywania konfliktów.Subskrybenci globalnego priorytet subskrypcja musi być mniejsza niż 100 co jest priorytet wydawcy.

  • [ @ sync_type =] 'sync_type'
    Jest to typ synchronizacji subskrypcja .sync_typejest nvarchar(15), domyślna automatyczne.Może być automatyczne lub Brak.Jeżeli automatyczne, schematu i początkowych danych opublikowanych tabel są przenoszone do subskrybenta najpierw.Jeżeli Brak, to zakłada, że abonent ma już schemat i początkowych danych opublikowanych tabel.Tabele systemowe i danych zawsze są przenoszone.

    Ostrzeżenie

    Nie zaleca się określenie wartości Brak.Aby uzyskać więcej informacji, zobacz temat Inicjowanie subskrypcji korespondencji seryjnej bez migawki.

  • [ @ Opis =] 'description'
    Jest krótki opis tej ściągać subskrypcja.descriptionjest nvarchar(255), domyślna wartość NULL.Ta wartość jest wyświetlana przez Monitor replikacji w Przyjazna nazwa kolumna, które mogą być używane do sortowania subskrypcji dla monitorowanej publikacja.

Wartości kodów powrotnych

0 (sukces) lub 1 (błąd)

Uwagi

sp_addmergepullsubscription Służy do replikacja scalająca.

Jeśli za pomocą SQL Server agenta do synchronizacji subskrypcja, sp_addmergepullsubscription_agent procedura składowana muszą być uruchamiane przez subskrybenta do tworzenia agenta i zadanie do synchronizacji z publikacji.

Przykład

-- 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'AdventureWorks2008R2';
SET @hostname = N'adventure-works\david8';

-- At the subscription database, create a pull subscription 
-- to a merge publication.
USE [AdventureWorks2008R2Replica]
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'AdventureWorks2008R2';
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 [AdventureWorks2008R2Replica]
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

Uprawnienia

Tylko członkowie sysadmin stała rola serwera lub db_owner Stała rola bazy danych można wykonać sp_addmergepullsubscription.