The solution is a SQL Server Agent job with a single step. The step executes the three stored procedures from the database "msdb".
  1. sp_delete_backuphistory
  2. sp_purge_jobhistory
  3. sp_maintplan_delete_log
All procedures are in the schema "dbo".

The logging is in a file that is created on each execution and is placed in the standard SQL Server Errorlog directory.
In the beginning of the log the calculated oldest time is entered.

By default the job deletes history older than three months. This can be changed by altering the DATEADD() part of the script in the jobstep.

MSDN Library on the stored procedures in the database "msdb" and the T-SQL commands.

Last edited Aug 24, 2010 at 8:22 PM by NielsGrove, version 15


No comments yet.