Trigger distribution job on completion of snapshot job

  • Since 30-Aug, the snapshot agent is running for more than 15mins, the interval between the snapshot & subscriber job is 15mins, time increase could possibly due to increase in data, I saw the snapshot size was near to 7 gigs which usually remained between 5-6 gigs on an average.

    Since the Snapshot job didn't complete before the subscriber job started, it didn't find a complete snapshot & failed to replicate the data & became inactive.

    I can very well increase the time between both the jobs, but that will just be a temp workaround.

    I wanted to check how can this situation be handled. Can a triggers be set that can trigger the distribution job as soon as the snapshot jobs completes.

    Apprently, i don't have any working knowledge with triggers, apprecaite if you could provide me with a script or something that I can use to make the Distribution job dependent on Snapshot.

    This has become a pain for me, please give me a permanent solution.

    Thanks

    Asir

  • asir83 (9/3/2012)


    Since 30-Aug, the snapshot agent is running for more than 15mins, the interval between the snapshot & subscriber job is 15mins, time increase could possibly due to increase in data, I saw the snapshot size was near to 7 gigs which usually remained between 5-6 gigs on an average.

    Since the Snapshot job didn't complete before the subscriber job started, it didn't find a complete snapshot & failed to replicate the data & became inactive.

    I can very well increase the time between both the jobs, but that will just be a temp workaround.

    I wanted to check how can this situation be handled. Can a triggers be set that can trigger the distribution job as soon as the snapshot jobs completes.

    Apprently, i don't have any working knowledge with triggers, apprecaite if you could provide me with a script or something that I can use to make the Distribution job dependent on Snapshot.

    This has become a pain for me, please give me a permanent solution.

    Thanks

    Asir

    You can use system stored procedure sp_start_job to start the subscriber job after the snapshot agent has completed. It can be done as :

    1. Add a new step of type "Transact-SQL Script" in the Snapshot Agent Job

    2. This new step should be the last step to execute after all previous steps have successfully executed

    3. Write below command in this step:

    EXECUTE msdb.dbo.sp_start_job @job_name='PutSubscriberJobNameHere'

    Once this has been configured you can disable the schedule of the subscriber job so that it only runs after snapshot job has completed.


    Sujeet Singh

  • U da Man...... 🙂

    Bet this is what I was looking for, let me try this...Thanks a lot Buddy, apprecaite ur prompt reply.

  • Hey,

    I have one more question, what if the subscriber is a pull subscription & the job is created on different instance?

    How can we call the subscriber job remotely?

    Thanks

    Asir

  • asir83 (9/4/2012)


    Hey,

    I have one more question, what if the subscriber is a pull subscription & the job is created on different instance?

    How can we call the subscriber job remotely?

    Thanks

    Asir

    I think above said stored procedure can be executed via a linked server also. Link servers are not very good when it comes to performance but in this particular case they may be useful.


    Sujeet Singh

  • I see, in that case I have to provide access to MSDB, while creating Linked server.

    But thanks for your suggestion, that should work as far as I see.

    Thanks Man

  • do have your servers running on different id's?.

    if it is same id why access change is required?

    Regards
    Durai Nagarajan

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply