Scheduling a job within a job

  • Can a job schedule another job within sqlserver? I know I can add multiple steps and have multiple DTS packages within the job, but I am trying to avoid having many steps within one job and categorize certain jobs. Thanks.

  • You could run an sp_startjob as a TSQL step within the DTS, however it's not going to wait until the other job has completed before it goes on to the next step.



    Shamless self promotion - read my blog http://sirsql.net

  • Script the job (right click, all tasks, generate sql script), then pull the code out that creates the schedule.  Insert that code into your job.  Use sp_add_jobschedule to add a new schedule or sp_update_jobschedule to change an existing schedule.  BOL has documentation for the 2 procedures.

    Steve

  • Even simpler - take Nicholas' suggestion (sp_start_job) and insert it into your scheduled job, ie, NOT your DTS package. You will then have a step dependency. Your first job needs to complete its job steps before it reached your newly inserted final job step (unless you choose otherwise).

    Steve  

  • Thanks for the suggestions. I tried Steve's suggestion and it works great!

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

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