How to: Synchronize a Push Subscription (Replication Programming)

Push subscriptions can be synchronized programmatically and on-demand by invoking the appropriate replication agent executable file from the command prompt. The replication agent executable file that is invoked will depend on the type of publication to which the push subscription belongs.

To start the Distribution Agent to synchronize a push subscription to a transactional publication

  1. From the command prompt or in a batch file at the Distributor, execute distrib.exe. Specify the following command-line arguments:

    • -Publisher
    • -PublisherDB
    • -Distributor
    • -Subscriber
    • -SubscriberDB
    • -SubscriptionType = 0

    If you are using SQL Server Authentication, you must also specify the following arguments:

    • -DistributorLogin
    • -DistributorPassword
    • -DistributorSecurityMode = 0
    • -PublisherLogin
    • -PublisherPassword
    • -PublisherSecurityMode = 0
    • -SubscriberLogin
    • -SubscriberPassword
    • -SubscriberSecurityMode = 0
      ms147377.security(en-US,SQL.90).gifSecurity Note:
      When possible, use Windows Authentication.

To start the Merge Agent to synchronize a push subscription to a merge publication

  1. From the command prompt or in a batch file at the Distributor, execute replmerg.exe. Specify the following command-line arguments:

    • -Publisher
    • -PublisherDB
    • -Publication
    • -Distributor
    • -Subscriber
    • -SubscriberDB
    • -SubscriptionType = 0

    If you are using SQL Server Authentication, you must also specify the following arguments:

    • -DistributorLogin
    • -DistributorPassword
    • -DistributorSecurityMode = 0
    • -PublisherLogin
    • -PublisherPassword
    • -PublisherSecurityMode = 0
    • -SubscriberLogin
    • -SubscriberPassword
    • -SubscriberSecurityMode = 0
      ms147377.security(en-US,SQL.90).gifSecurity Note:
      When possible, use Windows Authentication.

Example

The following example starts the Distribution Agent to synchronize a push subscription.

REM -- Declare the variables.
SET Publisher=%instancename%
SET Subscriber=%instancename%
SET PublicationDB=AdventureWorks
SET SubscriptionDB=AdventureWorksReplica 
SET Publication=AdvWorksProductsTran

REM -- Start the Distribution Agent with four subscription streams.
REM -- The following command must be supplied without line breaks.
"C:\Program Files\Microsoft SQL Server\90\COM\DISTRIB.EXE" -Subscriber %Subscriber% 
-SubscriberDB %SubscriptionDB% -SubscriberSecurityMode 1 -Publication %Publication% 
-Publisher %Publisher% -PublisherDB %PublicationDB% -Distributor %Publisher% 
-DistributorSecurityMode 1 -Continuous -SubscriptionType 0 -SubscriptionStreams 4 

The following example starts the Merge Agent to synchronize a push subscription.

REM -- Declare the variables.
SET Publisher=%instancename%
SET Subscriber=%instancename%
SET PublicationDB=AdventureWorks
SET SubscriptionDB=AdventureWorksReplica 
SET Publication=AdvWorksSalesOrdersMerge

REM -- Start the Merge Agent.
REM -- The following command must be supplied without line breaks.
"C:\Program Files\Microsoft SQL Server\90\COM\REPLMERG.EXE"  -Publisher %Publisher% 
-Subscriber  %Subscriber%  -Distributor %Publisher% -PublisherDB  %PublicationDB% 
-SubscriberDB %SubscriptionDB% -Publication %Publication% -PublisherSecurityMode 1 
-OutputVerboseLevel 3  -Output -SubscriberSecurityMode 1  -SubscriptionType 0 
-DistributorSecurityMode 1 

See Also

Tasks

How to: Synchronize a Push Subscription (RMO Programming)

Other Resources

How to: Synchronize a Push Subscription (SQL Server Management Studio)

Help and Information

Getting SQL Server 2005 Assistance