Monday, September 24, 2007

SQL Server@ Query To See the Execution History of SQL JOBS

I have made a couple of SQL jobs that are scheduled accordingly to perform some specific tasks. I wanted to know whether the jobs are executed accordingly or not? And what are the results of the execution? Means success or failure. And finally, I created a query for this purpose after looking into the MSDB. Here is it:

USE MSDB

SELECT j.name,h.run_status,h.run_date,h.run_time, h.run_duration,h.server, h.message
FROM sysjobhistory h,sysjobs j
WHERE h.job_id=j.job_id
ORDER BY run_date desc ,run_time desc

Here are the results: (NOTE: I have omitted the Message column here)
-----------------------------------------------------------------------------
DataEntryHHReports 1 20070921 121000 0 CORFXSQL01
DataEntryHHReports 1 20070921 121000 1 CORFXSQL01
DataEntryHHReports 0 20070914 121301 0 CORFXSQL01
DataEntryHHReports 2 20070914 121001 0 CORFXSQL01
DataEntryHHReports 0 20070914 121000 301 CORFXSQL01
GEServiceEntries 1 20070911 0 0 CORFXSQL01
GEServiceEntries 1 20070911 0 1 CORFXSQL01
DataEntryHHReports 1 20070907 121000 1 CORFXSQL01
DataEntryHHReports 1 20070907 121000 1 CORFXSQL01
DataEntryHHReports 1 20070831 121001 0 CORFXSQL01
DataEntryHHReports 1 20070831 121000 1 CORFXSQL01
DataEntryHHReports 1 20070824 121001 0 CORFXSQL01
DataEntryHHReports 1 20070824 121000 1 CORFXSQL01
DataEntryHHReports 1 20070817 121000 0 CORFXSQL01
DataEntryHHReports 1 20070817 121000 0 CORFXSQL01
GEServiceEntries 1 20070811 0 0 CORFXSQL01
GEServiceEntries 1 20070811 0 0 CORFXSQL01


No comments: