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.
Author |
Topic |
Ali Chadorbaf
Starting Member
44 Posts |
Posted - 2007-09-16 : 17:25:56
|
HiLet’s say I have 4 jobs (e.g.: Job1, Job2, Job3, Job4); each has 10 steps.I need to add a condition at the beginning of each job to prevent starting if another one is currently running (in progress). I was hoping following statement works but it does not.if exists (select 1 from msdb..sysjobs j join msdb..sysjobhistory h on j.job_id =h.job_id where ltrim(j.name) like 'Job%' and h.step_id =0 -- Job Outcome and h.run_status =4 -- in progress)beginraiserror('Please wait.....currently another load is in progress.',16,1)returnend |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-09-16 : 17:56:04
|
Try msdb..sp_help_job. |
 |
|
|
|
|