Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I view full SQL Job History?

In SQL Server Management Studio, when I "View History" for a SQL Job, I'm only shown the last 50 executions of the Job.

How can I view a full log of every execution of a SQL Job since it was created on the server?

like image 384
Curtis Avatar asked Oct 13 '11 12:10

Curtis


People also ask

Where is SQL job history stored?

SQL Server stores job information in the MSDB system tables. The table that stores historical job executions is msdb. dbo. sysjobhistory and the date/time information as well as the duration of the job execution is stored a little different than what you will see in most system tables.

How long does SQL Server keep job history?

Since we can only keep 10 history rows for any single job, the earlier execution gets truncated. SQL Server holds onto step 0 but deletes the history for steps 1 and 2. There is an also issue if you only want to keep an 8- or 12-hour rolling window of job history.


2 Answers

The SQL Server Job system limits the total number of job history entries both per job and over the whole system. This information is stored in the MSDB database.

Obviously you won't be able to go back and see information that has been since discarded, but you can change the SQL Server Agent properties and increase the number of entries that will be recorded from now on.

In the SQL Server Agent Properties:

  • Select the History page
  • Modify the 'Maximum job history log size (rows)' and 'Maximum job history rows per job' to suit, or change how historical job data is deleted based on its age.

It won't give you back your history, but it'll help with your future queries!

like image 80
Jeremy Smyth Avatar answered Sep 19 '22 22:09

Jeremy Smyth


I'm pretty sure job history is stored somewhere in a dedicated database in SQL Server itself. If this is the case, you can use SQL Server Profiler to intercept SQL statements sent by SQL Server Management Studio and find out names of tables, etc.

like image 33
Anton Gogolev Avatar answered Sep 19 '22 22:09

Anton Gogolev