Search

Tuesday, July 26, 2011

How to check restore history of a database

Declare @DBName varchar(255)
Set @DBName = ''
Select top 10

destination_database_name,

RH.restore_date,

BUS.server_name as 'SourceServer',

BUS.database_name as 'SourceDB',

BUS.backup_start_date,

BUS.type,

BMF.physical_device_name
from msdb.dbo.restorehistory RH
Join msdb.dbo.backupset BUS on BUS.backup_set_id = RH.backup_set_id
Join msdb.dbo.backupmediafamily BMF on BMF.media_set_id = BUS.media_set_id
where RH.destination_database_name = @DBName
Order by RH.restore_date desc

No comments:

Post a Comment