sp_addpullsubscription (Transact-SQL)
Adds a pull subscription to a snapshot or transactional publication. This stored procedure is executed at the Subscriber on the database where the pull subscription is to be created.
sp_addpullsubscription [ @publisher= ] 'publisher'
[ , [ @publisher_db= ] 'publisher_db' ]
, [ @publication= ] 'publication'
[ , [ @independent_agent= ] 'independent_agent' ]
[ , [ @subscription_type= ] 'subscription_type' ]
[ , [ @description= ] 'description' ]
[ , [ @update_mode= ] 'update_mode' ]
[ , [ @immediate_sync= ] immediate_sync ]
sp_addpullsubscription is used in snapshot replication and transactional replication.
Security Note
|
|---|
|
For queued updating subscriptions, use SQL Server Authentication for connections to Subscribers, and specify a different account for the connection to each Subscriber. When creating a pull subscription that supports queued updating, replication always sets the connection to use Windows Authentication (for pull subscriptions, replication cannot access metadata at the Subscriber required to use SQL Server Authentication). In this case, you should execute sp_changesubscription to change the connection to use SQL Server Authentication after the subscription is configured. |
If the MSreplication_subscriptions (Transact-SQL) table does not exist at the Subscriber, sp_addpullsubscription creates it. It also adds a row to the MSreplication_subscriptions (Transact-SQL) table. For pull subscriptions, sp_addsubscription (Transact-SQL) should be called at the Publisher first.
-- 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; SET @publication = N'AdvWorksProductTran'; SET @publisher = $(PubServer); SET @publicationDB = N'AdventureWorks'; -- At the subscription database, create a pull subscription -- to a transactional publication. USE [AdventureWorksReplica] EXEC sp_addpullsubscription @publisher = @publisher, @publication = @publication, @publisher_db = @publicationDB; -- Add an agent job to synchronize the pull subscription. EXEC sp_addpullsubscription_agent @publisher = @publisher, @publisher_db = @publicationDB, @publication = @publication, @distributor = @publisher, @job_login = $(Login), @job_password = $(Password); GO

Security Note