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 2000 Forums
 Transact-SQL (2000)
 Checking if a SPROC is running

Author  Topic 

CartesianJoin
Starting Member

11 Posts

Posted - 2004-06-04 : 19:24:21
I have a stored procedure which is set via an SQL agent to fire a stored proc every 5 minutes. Is there a way to determine if the stored proc is already running before I run it again?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-04 : 19:27:40
The job won't fire if the job is still executing. So let's say your stored proc is taking 6 minutes to execute and your job is scheduled to run every 5 minutes. So the first time it executes it starts at 1:00. The next time it tries to execute will be 1:05, but that won't happen since the 1:00 run hasn't finished. The next actual run will be 1:10.

Tara
Go to Top of Page

CartesianJoin
Starting Member

11 Posts

Posted - 2004-06-04 : 19:31:22
Excellent. Just what I had hoped. Thanks for the response.
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-05 : 16:27:21
FYI, you can also get the information from:

EXEC msdb.dbo.sp_get_composite_job_info

This proc returns the same values you see when you look at Jobs in Enterprise Manager. It includes whethere the job is executing, status, completion status, etc.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -