MSSQL - Finding the database restore history

7. August 2012 21:12

 

Did you know you can view the database restore history from MSSQL server. The following SQL will provide a list of all database restores that have been performed on a server at some point.

 

 

SELECT 
	destination_database_name, server_name AS 'SourceServer', database_name AS 'SourceDB', physical_device_name, type, backup_start_date, restore_date
	FROM msdb.dbo.restorehistory AS rh
		INNER JOIN msdb.dbo.backupset AS bs ON bs.backup_set_id = rh.backup_set_id
		INNER JOIN msdb.dbo.backupmediafamily AS bmf ON bmf.media_set_id = bs.media_set_id
	ORDER BY restore_date DESC;

 

 

It will produce output that looks like this.

 

 

Stev	DC01	Stev	E:\MSSQL-Backup\Stev.bak	D	2011-09-17 08:43:58.000	2011-09-17 09:10:25.283

 

E-mail Kick it! DZone it! del.icio.us Permalink


Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading