?
Solved

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

Posted on 2004-08-11
3
Medium Priority
?
479 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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

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