Dela via


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

  • 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

      Security noteSecurity Note

      When possible, use Windows Authentication.

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

  • 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

      Security noteSecurity 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=AdventureWorks2008R2
SET SubscriptionDB=AdventureWorks2008R2Replica 
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\100\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=AdventureWorks2008R2
SET SubscriptionDB=AdventureWorks2008R2Replica 
SET Publication=AdvWorksSalesOrdersMerge

REM -- Start the Merge Agent.
REM -- The following command must be supplied without line breaks.
"C:\Program Files\Microsoft SQL Server\100\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