Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Start job and wait of completion

Author  Topic 

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-08-20 : 16:08:13
Does anyone know of a way to start a job in a script and wait for it to complete before executing the next command:
1. Run job 1 and wait for it complete.
2. Then, run job 2 and wait for it complete.
3. Then, run job 3 and wait for it complete.
etc.



CODO ERGO SUM

X002548
Not Just a Number

15586 Posts

Posted - 2007-08-20 : 16:26:48
Only thing I can think of is to have the jobs update a table with it's status and loop until the status changes

But if you just schedule the jobs with many steps, won't they wait until they complete?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-08-20 : 17:02:28
quote:
Originally posted by X002548
...But if you just schedule the jobs with many steps, won't they wait until they complete?...


I wanted to setup an individual job for each step to make it easy to rerun individual steps, but would like to be able to run each individual job as a step of another job.


An alternative solution would be a way to start a job at an individual step, and run only that step when I do a rerun.


CODO ERGO SUM
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-20 : 17:22:24
You can query sysjobhistory to see if the job completed. SQL Server adds a record to this table when a job/step finishes execution.
The run_status should have an appropriate value.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -