top of page

Find Job History for all SQL Server Agent Jobs.

Use msdb

go

select distinct j.Name as "Job Name", --j.job_id,

case j.enabled

when 1 then 'Enable'

when 0 then 'Disable'

end as "Job Status", jh.run_date as [Last_Run_Date(YY-MM-DD)] ,

case jh.run_status

when 0 then 'Failed'

when 1 then 'Successful'

when 2 then 'Retry'

when 3 then 'Cancelled'

when 4 then 'In Progress'

end as Job_Execution_Status

from sysJobHistory jh, sysJobs j

where j.job_id = jh.job_id and jh.run_date =

(select max(hi.run_date) from sysJobHistory hi where jh.job_id = hi.job_id )-- to get latest date

Recent Posts

See All
SQL Server Profiler Trace

--Import multiple trace file in sql Table. --All the rollover files will be automatically imported --provide number tracefile to capture...

 
 
 
Find All Primary Key in SQL Server

select schema_name(tab.schema_id) as [schema_name], pk.[name] as pk_name, substring(column_names, 1, len(column_names)-1) as [columns],...

 
 
 

Comments


bottom of page