Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Checking job status from Stored Procedure

Author  Topic 

cornelius
Starting Member

11 Posts

Posted - 2007-05-09 : 12:24:51
Hello
I have a job that runs every 30 seconds, and when it runs- I disable another job that might cause an error when running at the same time with the first job. I disable the job using sp_update_job function.
The problem is that once in a while the second job is already running when sp_update_job is issued, and the first job (which was unsuccessful with disabling the second job) ends with an error.
I want to add a check to see if the first job is currently running, and if so- stop it using sp_stop_job.
I know that the function sp_help_job can supply information regarding a job, but I don't know how to use it from a TSQL procedure. The function returns a very large ResultSet and I only need to get the current_execution_status.
Can anybody help me with the syntax to do so?
I also tried using sp_stop_job function with try/catch blocks. but apparently the catch block does not catch the error generated when I try to stop a job that is not running at the moment.

Thank you
Nili

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-05-09 : 12:54:17
dupe. please don't cross post.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=83324


www.elsasoft.org
Go to Top of Page
   

- Advertisement -