Snapshot replication agent can be controlled by programmatically described below,
You can copy and paste below code in a batch file and then execute that batch file after replacing the required information with your actual parameters. It will execute the snapshot agent.
Required Parameters:
Publisher: instance name
PublicationDB: publisher database name
Publication: publicaion name
Replicationtype: 1 for Transactional Replicaion, 2 for Merg Replication, skip it for Snapshot replication
Distributor: Distributor instance name
DistributorSecurityMode: 0 for SQL Server authentication that is default, and 1 for window authentication
OutputVerboseLevel: 0 for print only Error Messages, 1 for to print whole Progress report, and 2 for to print Both Error and Progress report Messages
Script for batch file:
SET Publisher=InstanceName
SET PublicationDB=AdventureWorks
SET Publication=AdvWorksSalesOrdersMerge
REM --Start the Snapshot Agent to generate the snapshot
"C:\Program Files\Microsoft SQL Server\90\COM\SNAPSHOT.EXE" -Publication %Publication% -Publisher %Publisher% -Distributor %Publisher% -PublisherDB %PublicationDB% -ReplicationType 2 -OutputVerboseLevel 1 -DistributorSecurityMode 1
It will execute the publication’s snapshot agent for merge type replication by using windows authentication mode and printing the whole progress report. Distributor and publisher are same, you can use different by defining another parameter for distributor.
No comments:
Post a Comment