Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-08-11
3
Medium Priority
?
480 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1204 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 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