Solved

How can you force a script to pause until sp_start_job has finished?

Posted on 2004-08-11
3
471 Views
Last Modified: 2012-06-27
I have a page of scripts, the first of which is an sp_start_job which copies over the data for the rest of the scripts to run off.  Right now, the sp_start_job procedure ends after the other scripts have already run.  I checked BOL and found no variable for sp_start_job to force it to finish efore proceeding.  How can I accomplish this or is there a better work around.  Right now, all I'm going to be able to do is split the script up on different pages and use a javascript timer to create a pause, but that's not ideal for a number of reasons, obviously.
0
Comment
Question by:fairoakian
  • 2
3 Comments
 
LVL 17

Expert Comment

by:BillAn1
ID: 11778701
sysjobhistory has a run_status column. You can check this to see when the job has completed
0
 
LVL 17

Accepted Solution

by:
BillAn1 earned 301 total points
ID: 11778749
here's how you could use it :

while exists (
select 1
from msdb..sysjobhistory jh join msdb..sysjobs j
on jh.job_id = j.job_id and name = @myjob and runstatus = 4)
begin
     ' twiddle your thumbs.....
end
0
 

Author Comment

by:fairoakian
ID: 11779254
Should have placed this in the SQL Server section, but got a great answer anyway.  Thanks.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question