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 |
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2008-05-06 : 12:46:30
|
I have jobs that run daily and I am trying to find a query that will give me the status of a job that is running. I'd like to schedule this query at a specific time daily so that I know what step the job is on. I'm not sure if there is a built in stored procedure that does this already or if anyone has the code. As always, any help is always greatful. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-06 : 12:49:51
|
sysjob and sysjobhistory could work. E 12°55'05.25"N 56°04'39.16" |
 |
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2008-05-06 : 13:12:45
|
I'm looking for something similar to the "Jobs" tab in SQL Server Enterprise Manager, under the "Status" column which usually says "Executing Job Step...". Would there be another system table containing that information? |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-05-06 : 13:24:12
|
join sysjobsteps and sysjobhistory |
 |
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2008-05-06 : 13:40:02
|
I have some jobs running, however, when I query the sysjobhistory table there aren't any rows that return the value 4 under the run_status column (4 meaning "in progress" status) which leads me to believe this isn't real time. Am I missing something? |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-05-06 : 17:56:36
|
You get in progress when job is running.Try this:select a.name,b.step_name(case b.run_status when '0' then 'failed' when '1' then 'succeeded' when '2' then 'retry' when '3' then 'Canceled' when '4' then 'In progress' end )as status,b.run_durationfrom dbo.sysjobhistory binner join dbo.sysjobs aon a.job_id=b.job_id |
 |
|
|
|
|