views:

174

answers:

1

We currently have merge replication set up to merge certain tables between two databases. I need to programmatically start one of the publications to make sure data has been synchronized prior to starting a certain job. SQL Server Books Online has not been too helpful.

So far, the only thing I have come up with is to use sp_start_job to start the merge replication sql job. Is it ok to do this?

Are there any other ways to programmatically start synchronizing a publication?

A: 

We ended up using the sp_start_job with the name of the merge replication publication. The only downside that we found was that the name of the sql job is dynamically generated when the publication is created so if the publication is drop and recreated, then the name will change. Other than that using sp_start_job has worked beautifully.

Couple other things:

  • The sql user was added to SQLAgentOperatorRole to allow the call to sp_start_job
  • sp_help_job was used to indicate if the job completed successfully before proceeding
Jeff Widmer