Gaurav (1/12/2009)
Hi AllI have set up the merge replication in SSMS (management studio). I am able to perform merge replication between subscriber and publisher. But the synchronization process has to be started manually.
I am using a script to start the synchronization but I am getting some errors.
Script and error details are as follows
Script:
declare @cmd varchar(4000),
@publisher varchar(400),
@publicationDB varchar(400),
@publication varchar(400),
@subscriptionDB varchar(400),
set @publisher='publisher_name'
set @publicationDB='db_name'
set @publication='publication_name'
set @subscriptionDB='db_name1'
/* The following command should be all on one line. It is displayed on multiple
lines here because of the limitations of the page. */
set @cmd="C:\Program Files\Microsoft SQL Server\90\COM\REPLMERG.EXE" -Publication @publication -Publisher @publisher -Subscriber @publisher -Distributor @publisher -PublisherDB @publicationDB -SubscriberDB @subscriptionDB -PublisherSecurityMode 1 -PublisherLogin @login -PublisherPassword @password -OutputVerboseLevel 2 -SubscriberSecurityMode 1 -SubscriberLogin @login -SubscriberPassword @password -SubscriptionType 1 -DistributorSecurityMode 1 -DistributorLogin @login -DistributorPassword @password -Validate 3 -ParallelUploadDownload 0
exec xp_cmdshell '@cmd'
go
Error:
Msg 102, Level 15, State 1, Line 17
Incorrect syntax near '@publication'.
Any idea how can I get rid of this error?
Thanks
Gaurav
The parameters should be decoded on the @cmd variable like:
/* The following command should be all on one line. It is displayed on multiple
lines here because of the limitations of the page. */
set @cmd='"C:\Program Files\Microsoft SQL Server\90\COM\REPLMERG.EXE" -Publication ' + @publication + ' -Publisher ' + @publisher + ' -Subscriber ' + @publisher + ' -Distributor ' + @publisher + ' -PublisherDB ' + @publicationDB + ' -SubscriberDB ' + @subscriptionDB +' -PublisherSecurityMode 1 -PublisherLogin ' + @login + ' -PublisherPassword '+ @password + '-OutputVerboseLevel 2 -SubscriberSecurityMode 1 -SubscriberLogin ' + @login + ' -SubscriberPassword ' + @password + ' -SubscriptionType 1 -DistributorSecurityMode 1 -DistributorLogin ' + @login + ' -DistributorPassword ' + @password + ' -Validate 3 -ParallelUploadDownload 0 '
* Noel