Saturday, December 22, 2007

Last Restore Date in MSSQL

I regularly take backups of three databases from a production SQL Server 2005, and restore to as many as four different development servers, for testing with different OS's and hardware configurations. I created this procedure in the master database on each dev server that will display the last restore dates for all the databases:


CREATE PROC dbo.procLastRestoreDates
AS
SELECT
destination_database_name,
MAX(restore_date) AS LastRestoreDate,
restore_type
FROM
msdb.dbo.restorehistory
GROUP BY
destination_database_name,
restore_type

No comments: