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

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!
ravichand-sqlAsked:
Who is Participating?
 
jorge_torizConnect With a Mentor Research & Development ManagerCommented:
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
 
momi_sabagCommented:
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
 
ravichand-sqlAuthor Commented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Anthony PerkinsCommented:
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
 
ravichand-sqlAuthor Commented:
I am so sorry about this, and will not be repeating this again..
0
 
jorge_torizResearch & Development ManagerCommented:
And?, my answer contains a reasonable approach to accomplish the task?, why this question would be closed without any points?
0
 
DBAduck - Ben MillerConnect With a Mentor Principal ConsultantCommented:
I use this.

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

It is a start job and wait proc.
0
All Courses

From novice to tech pro — start learning today.