Solved

Stored Proc to kick off the job and wait till it completes

Posted on 2013-12-02
7
428 Views
Last Modified: 2014-01-03
Hi Experts,

I need your help in creating a stored procedure which will kick off a sql server job (job has multiple steps). Using "msdb.dbo.sp_start_job" will just kicks off the job. But I want my stored procedure to kick off the job and wait till it completes.

I do not want to use WAITFOR DELAY function.

Please help me out!!

Thanks in advance!
0
Comment
Question by:ravichand-sql
7 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 39691415
why do you want to wait for the job?
why not use waitfor delay?

maybe you could use the internal queues for that
have the stored procedure start the job and then wait for a message in a queue (which the job will place in it's last step) but it is very complicated
0
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 250 total points
ID: 39697536
Does your stored procedure need to use information that is generated by your job?

I would put the code that follow the msdb.dbo.sp_start_job inside another stored procedure and then execute this stored procedure as the last step of your job.
0
 

Author Comment

by:ravichand-sql
ID: 39750392
Hello Moderator,

Please close this question, as I have not got the required answer and I do not need help in this question.

Sorry for the late response
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39750489
ravichand-sql,

Please close this question
That is your responsibility.  You should request that the thread be deleted and if no one objects it will be done.

Next time try and participate by providing meaningful feedback instead of abandoning the question.
0
 

Author Comment

by:ravichand-sql
ID: 39750523
I am so sorry about this, and will not be repeating this again..
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 39751893
And?, my answer contains a reasonable approach to accomplish the task?, why this question would be closed without any points?
0
 
LVL 24

Assisted Solution

by:DBAduck - Ben Miller
DBAduck - Ben Miller earned 250 total points
ID: 39754989
I use this.

http://blog.boxedbits.com/archives/124

It is a start job and wait proc.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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