Solved

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

Posted on 2013-12-02
7
415 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now