Solved

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

Posted on 2013-12-02
7
424 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

16 Experts available now in Live!

Get 1:1 Help Now