April 10, 2013 at 3:50 pm
Hello I have a several SQL JObs I need to run in sequence. For some reason when I run a job which I already setup with all jobs I need is not running correctly.
And SQL Server is not waiting for the job to be completed before continuing to the next job.
How can I accomplish this?
Any help is appreciated!! thanks
April 10, 2013 at 4:01 pm
Are you using sp_start_job to execute your jobs? If so, that procedure is asyncronous, meaning it returns immediately after starting the job and doesn't wait for it to complete.
April 11, 2013 at 7:58 am
Yes I am using the sp_start command. So which one should I use to wait until a job finish then start the next one...is there any way to do this?
April 11, 2013 at 11:02 am
Is there a reason why you have it set up as multiple jobs instead of just one job with multiple steps? If there is, I'm mot saying it's the best way to do this, but could you "daisy chain" them? Remove your job that fires off all the jobs and leave your individual ones and just add a second step for each one.
I.E.
Job1
Step 1 - Do something
Step 2 - sp_start_job("Job2")
Job2
Step 1 - Do something else
Step 2 - sp_startjob("Job3)
etc...
You can also use sp_help_job to check the status of your jobs as well.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply