Thursday, January 14, 2016

How to get the Last Restored Database details

How to get SQL Last restored database details

Hi Friends,

Sometimes we need the details of database which restored last, following query will help you to get those details


SELECT
Destination_Database_Name,
    Restore_Date,
database_name AS Source_Database,
    Physical_device_name as Backup_File_Used_To_Restore
FROM
msdb.dbo.restorehistory rh
INNER JOIN msdb.dbo.backupset bs
ON rh.backup_set_id=bs.backup_set_id
INNER JOIN msdb.dbo.backupmediafamily bmf
ON bs.media_set_id =bmf.media_set_id
ORDER BY
[rh].[restore_date] DESC


Thanks.

No comments: