Tara Kizer Blog

Tara Kizer

How to delete backup and restore history from msdb

Have you ever wondered why your msdb database is unusually large?  Did you know that SQL Server keeps historical information about every backup and restore operation in the msdb database?  It is recommended that you purge this backup and restore historical information on a scheduled basis.  Microsoft provides sp_delete_backuphistory to do the purge.  In SQL Server 2000, the stored procedure ran very slow as it cursored through the data.  As a result of the slowness, I wrote my own purge stored procedure.  I blogged about this a few years back. 

When we upgraded our systems to SQL Server 2005, I was curious if Microsoft had made sp_delete_backuphistory more efficient as I did not want to maintain my custom code.  I was ecstatic to find out that my wish had been granted.  I'll have to ask for money in my next wish before I run out of wishes!

For those of you who use my custom code (or similar code) to delete the backup/restore history in SQL Server 2005, start using sp_delete_backuphistory instead.

Legacy Comments


Naresh Behera
2008-08-01
re: How to delete backup and restore history from msdb
I take the backup of the database with a specific name but i want to delete this after restore this.so please send me how to delete this database(which i take the name with).

Tara
2008-08-01
re: How to delete backup and restore history from msdb
Naresh, I don't fully understand your question. But perhaps all you need is DROP DATABASE dbName.