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 |
DLTaylor
Posting Yak Master
136 Posts |
Posted - 2010-11-15 : 09:01:07
|
I am using SQL 2005 sp3.I have number of jobs on a server that run every 20 mins and complete usually within 3 to 5 mins.On occasions one will get stuck as ‘executing’ which effectively means that particular job would not run again until I intervened.For some reality… I have just found a Job running for 16hours – that usually lasts 3 minutes!! ;-(Does anyone have any T-sql that will return records if a job takes longer than a given time e.g. 30 min – I can then add this to an alert.Or any advice would be great!Thanks |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-11-15 : 18:59:24
|
[CODE]use msdbdeclare @DeltaMinutes int = 10select j.name, jh.run_duration duration_in_minutesfrom msdb.dbo.sysjobs jinner join msdb.dbo.sysjobhistory jh on jh.job_id = j.job_id where jh.run_status = 4and ((run_duration / 10000) * 60) + ((run_duration % 10000) / 100) > @DeltaMinutesorder by run_duration DESC[/CODE]=======================================In all life one should comfort the afflicted, but verily, also, one should afflict the comfortable, and especially when they are comfortably, contentedly, even happily wrong. -John Kenneth Galbraith, economist (1908-2006) |
 |
|
|
|
|