Sql server Agent

  • I have a job that is based to excute basesd on another job.

    What i am planning to implement is disable the primary job, wait for it to finish and exceute the other job, but i don't have any idea to implement it.

  • Look at sp_start_job in Books Online. You should just be able to run the secondary job as part of the primary.

  • Mark Thank for you reply

    But here once i disable the primary job i want to make sure it has completed execution and then have the sql server agent start the other job

  • I guess I don't know if these need to be two seperate jobs, but if not one option would be to combine all of the tasks of both into one, and let each step feed the next.

    Otherwise if they have to be seperate jobs then would have to call out and start the first job then loop and call sp_help_job until it's done. then you can proceed with the next step.

  • Once you start a job, it will continue to execute until it either completes or hits an error. Even if you disable it, it will continue to execute the steps.

    Therefore, in order to get what you want, build your first job as you want. However, as the very last step, use sp_start_job to kick off the second job. As soon as the first job executes this statement, it'll complete. And SQL Server Agent will have started working on the second job.

    If you're looking to disable the first job automatically, make that your very first step and use sp_update_job to change its enabled status to 0.

    K. Brian Kelley
    @kbriankelley

  • Thanks,

    Brian this is what i wanted.

    Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!

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

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