Creating a Subscription with SQL Statements

The following is an example that shows the creation of the publication shown above using SQL statements, rather than the wizard.

The following stored procedures are used:

  • sp_addsubscription stored procedure adds a subscription to a publication and sets the subscriber status. The stored procedure runs on the publication database on the publisher.

  • sp_addpushsubscription_agent stored procedure adds a new scheduled agent job. This job is used to synchronize a push subscription to a transactional publication. It is also executed on the publisher on the publication database.

The example is shown here:

-----------------BEGIN: Script to be run at Publisher 'PTC9'----------------- use [AdventureWorks] exec sp_addsubscription ...

Get Microsoft® SQL Server™ 2005 Administrator's Companion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.