Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Job History Filter by Run Date

$
0
0
I have this script that I'm trying to filter the results of the Job History to the day prior at 1800 hours.It return dates prior to what I have in the WHERE clause.What should the WHERE Clause look like? [code="sql"]USE msdbGoSELECT j.name JobName,h.step_name StepName, CONVERT(CHAR(10), CAST(STR(h.run_date,8, 0) AS dateTIME), 111) RunDate, STUFF(STUFF(RIGHT('000000' + CAST ( h.run_time AS VARCHAR(6 ) ) ,6),5,0,':'),3,0,':') RunTime, h.run_duration StepDuration,case h.run_status when 0 then 'failed'when 1 then 'Succeded' when 2 then 'Retry' when 3 then 'Cancelled' when 4 then 'In Progress' end as ExecutionStatus, h.message MessageGeneratedFROM sysjobhistory h inner join sysjobs jON j.job_id = h.job_idWHERE CONVERT(CHAR(10), CAST(STR(h.run_date,8, 0) AS dateTIME), 111) >= '2015-03-30 18:0:00.000' -- This returns dates prior to 3/30/2015ORDER BY j.name, h.run_date, h.run_timeGO[/code]I also need the start and stop time.Ideally it would reflect the information for each step.Any help would be greatly appreciated.

Viewing all articles
Browse latest Browse all 6525

Trending Articles