Aracılığıyla paylaş


sp_link_publication (Transact-SQL)

Yayımcı için bağlanırken hemen güncelleştirme abonelikleri eşitleme Tetikleyiciler tarafından kullanılan yapılandırma ve güvenlik bilgilerini ayarlar.Bu saklı yordam, abonelik veritabanı abone adresindeki yürütülür.

Güvenlik notuGüvenlik Notu

Yayımcı ile yapılandırırken bir uzak Dağıtımcı, sağlanan da dahil olmak üzere tüm parametreler için değerler job_login ve job_password, için dağıtıcı düz metin olarak gönderilirBu saklı yordam yürütmeden önce Yayımcı ve kendi uzak dağıtımcı arasında bağlantı şifrelemek.Daha fazla bilgi için bkz: SQL Server bağlantıları şifreleme.

Önemli notÖnemli

Under certain conditions, this stored procedure can fail if the Subscriber is running Microsoft SQL Server 2005 Service Pack 1 or later, and the Publisher is running an earlier version.Bu senaryoda, saklı yordam başarısız olursa, Yayımcı için yükseltme SQL Server 2005 Service Pack 1 veya sonrası.

Konu bağlantısı simgesiTransact-sql sözdizimi kuralları

Sözdizimi

sp_link_publication [ @publisher = ] 'publisher' 
        , [ @publisher_db = ] 'publisher_db' 
        , [ @publication = ] 'publication' 
        , [ @security_mode = ] security_mode
    [ , [ @login = ] 'login' ]
    [ , [ @password = ]'password' ]
    [ , [ @distributor = ] 'distributor' ]

Bağımsız değişkenler

  • [ @ publisher=] 'publisher'
    Is the name of the Publisher to link to.publisher is sysname, with no default.

  • [ @ publisher_db=] 'publisher_db'
    Is the name of the Publisher database to link to.publisher_db is sysname, with no default.

  • [ @ yayın=] 'yayın'
    Is the name of the publication to link to.publication is sysname, with no default.

  • [ @ security_mode=] security_mode
    Is the security mode used by the Subscriber to connect to a remote Publisher for immediate updating.security_mode is int, and can be one of these values.Mümkünse Windows Kimlik Doğrulaması kullanın.

    Değer

    Açıklama

    0

    Kullandığı SQL Server Bu saklı yordam belirtilen kimlik doğrulama ile oturum açma login ve parola.

    NotNot
    Önceki sürümlerinde SQL Server, dinamik uzaktan yordam çağrısı (rpc) belirtmek için bu seçeneği kullanıldı.

    1

    Güvenlik bağlamını kullanır (SQL Server kimlik doğrulaması veya Windows kimlik doğrulaması) kullanıcının değişiklik yapmadan abone.

    NotNot
    Bu hesabın yeterli ayrıcalıklara sahip yayımcı adresindeki de bulunması gerekir.Windows kimlik doğrulaması kullanırken, güvenlik hesabını temsilci seçme desteklenmelidir.

    2

    Kullanılarak oluşturulan bir varolan, kullanıcı tanımlı bağlantılı sunucu oturumu kullanır sp_link_publication.

  • [ @ login=] 'login'
    Is the login.login is sysname, with a default of NULL.Bu parametre olmalıdır ne zaman belirtilen security_mode olan 0.

  • [ @ parola=] 'parola'
    Is the password.password is sysname, with a default of NULL.Bu parametre olmalıdır ne zaman belirtilen security_mode olan 0.

  • [ @distributor= ] 'distributor'
    Is the name of the Distributor.distributor is sysname, with a default of NULL.

Dönüş Kodu Değerleri

0 (başarılı) veya 1 (başarısız)

Açıklamalar

sp_link_publication hemen güncelleştirme abonelikleri işlem çoğaltma tarafından kullanılır.

sp_link_publication hem gönderme ve çekme abonelikleri için kullanılır.Veya önce abonelik oluşturulduktan sonra çağrılabilir.Bir girdi eklendi veya, güncelleştirilmiş MSsubscription_properties (Transact-SQL) Sistem tablo.

gönderme abonelikleri için giriş tarafından temizlenebilir sp_subscription_cleanup (Transact-SQL).Çekme abonelikleri için giriş tarafından temizlenebilir sp_droppullsubscription (Transact-SQL) veya sp_subscription_cleanup (Transact-SQL).Ayrıca çağrı sp_link_publication girişte temizlemek için bir null parolasıyla MSsubscription_properties (Transact-SQL) Sistem tablo için güvenlik konuları.

İçin yayımcı bağlandığında hemen bir güncelleştirme abone tarafından kullanılan varsayılan modu, Windows kimlik doğrulaması kullanarak bağlantı izin vermez.Windows kimlik doğrulaması modu ile bağlamak için bağlantılı sunucu olması gerekir küme Yayımcı ve hemen abone güncelleştirme kullanılması gereken bu bağlantı abone güncelleştirirken.Bu gerektirir sp_link_publication ile çalıştırılmak üzere security_mode = 2.Windows kimlik doğrulaması kullanırken, güvenlik hesabını temsilci seçme desteklenmelidir.

Örnek

-- 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 @publicationDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @login AS sysname;
DECLARE @password AS nvarchar(512);
SET @publication = N'AdvWorksProductTran';
SET @publicationDB = N'AdventureWorks2008R2';
SET @publisher = $(PubServer);
SET @login = $(Login);
SET @password = $(Password);

-- At the subscription database, create a pull subscription to a transactional 
-- publication using immediate updating with queued updating as a failover.
EXEC sp_addpullsubscription 
    @publisher = @publisher, 
    @publication = @publication, 
    @publisher_db = @publicationDB, 
    @update_mode = N'failover', 
    @subscription_type = N'pull';

-- Add an agent job to synchronize the pull subscription, 
-- which uses Windows Authentication when connecting to the Distributor.
EXEC sp_addpullsubscription_agent 
    @publisher = @publisher, 
    @publisher_db = @publicationDB, 
    @publication = @publication,
    @job_login = @login,
    @job_password = @password; 

-- Add a Windows Authentication-based linked server that enables the 
-- Subscriber-side triggers to make updates at the Publisher. 
EXEC sp_link_publication 
    @publisher = @publisher, 
    @publication = @publication,
    @publisher_db = @publicationDB, 
    @security_mode = 0,
    @login = @login,
    @password = @password;
GO

USE AdventureWorks2008R2;
GO

-- Execute this batch at the Publisher.
DECLARE @publication AS sysname;
DECLARE @subscriptionDB AS sysname;
DECLARE @subscriber AS sysname;
SET @publication = N'AdvWorksProductTran'; 
SET @subscriptionDB = N'AdventureWorks2008R2Replica'; 
SET @subscriber = $(SubServer);

-- At the Publisher, register the subscription, using the defaults.
USE [AdventureWorks2008R2]
EXEC sp_addsubscription 
    @publication = @publication, 
    @subscriber = @subscriber, 
    @destination_db = @subscriptionDB, 
    @subscription_type = N'pull', 
    @update_mode = N'failover';
GO

İzinler

Yalnızca üyeleri sysadmin sabit sunucu rolü olabilir yürütmek sp_link_publication.