Reduces the size of the backup and restore history tables by deleting the entries for backup sets older than the specified date. Additional rows are added to the backup and restore history tables after each backup or restore operation is performed; therefore, we recommend that you periodically execute sp_delete_backuphistory.

The backup and restore history tables reside in the msdb database.

USE msdb
GO
DECLARE @DaysToKeepHistory DATETIME
SET @DaysToKeepHistory = (SELECT CONVERT(VARCHAR(10), DATEADD(dd, -30, GETDATE()), 101))
EXEC sp_delete_backuphistory @DaysToKeepHistory
GO
Last modified: September 19, 2019

Author

Comments

Write a Reply or Comment