How to find out the last time your database was restored

Here is a short script that I got from my DBA (John Langston).
It will return the date time that your database was restored.

DECLARE @DatabaseName as varchar(50) SET @DatabaseName = ‘YOUR DATABASE NAME’

SELECT destination_database_name,max(restore_date) as restore_date from msdb..restorehistory WHERE destination_database_name = @DatabaseName GROUP BY destination_database_name

Advertisements

One thought on “How to find out the last time your database was restored

  1. Here is the code again without the line numbers and breaks (easier to copy)

    DECLARE @DatabaseName as varchar(50)
    SET @DatabaseName = ‘Accounting’

    SELECT destination_database_name,max(restore_date) as restore_date from msdb..restorehistory
    WHERE destination_database_name = @DatabaseName
    GROUP BY destination_database_name

Got something to add?

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