Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

List job name which didn't run today but supposed to run today. Expand / Collapse
Author
Message
Posted Saturday, November 03, 2012 5:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: 2 days ago @ 8:10 AM
Points: 21, Visits: 200
Hi,

I have one query.i face one issue almost every day.

We have lot of scheduled jobs configured ,some of jobs can't start on time as server may down at that time.

Can i get the query which will show 'that job didn't run today '
Post #1380698
Posted Monday, November 05, 2012 5:21 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 3:48 AM
Points: 3,125, Visits: 4,311
will this help:
;with LatestJobs AS
(SELECT Job_id, step_id, max(convert(varchar(8),run_date)+RIGHT('000000'+CONVERT(varchar(6), run_time),6)) As LastRun
from msdb.dbo.sysjobhistory
group by Job_id, step_id)
select j.job_id, j.name, next_run_date, next_run_time
from msdb.dbo.sysjobs j
join msdb.dbo.sysjobhistory h on h.job_id = j.job_id
join LatestJobs lj on lj.job_id = j.job_id and lj.step_id = h.step_id and lj.LastRun = convert(varchar(8),run_date)+RIGHT('000000'+CONVERT(varchar(6), run_time),6)
join msdb.dbo.sysjobschedules s on s.job_id = j.job_id
where h.run_date < s.next_run_date and h.run_time < s.next_run_time
and convert(date,convert(varchar(8),ISNULL(NULLIF(s.next_run_date,0),19000101)),112) < convert(date, getdate())

please do not hesitate to work and / or refine this further if it does not meet all your requirements


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1381011
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse