SQL Stuff

Find When Database Was Last Restored

You can see when the database was last restored, and who performed the restore ( or under what account the restore operation was run ). Just run this simple script. The results will also show you the ‘type’ or restore that was run.

use msdb;
set nocount on
select
‘restore date’ = convert(char, restore_date, 9) , ‘destination database’ = destination_database_name
, [user_name]
, ‘restore type’ =
case restore_type
when ‘D’ then ‘Database Restore’
when ‘F’ then ‘File Restore’
when ‘G’ then ‘Filegroup Restore’
when ‘I’ then ‘Differential Restore’
when ‘L’ then ‘Log Restore’
when ‘V’ then ‘Verifyonly’
end
from
msdb..restorehistory
order by
restore_date desc

Advertisements

Categories: SQL Stuff

Tagged as: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s