Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using sql server 2008, and I would like to know if a specific database has been restored from a device and when did it happened. Is it possible?

share|improve this question

migrated from Dec 4 '12 at 13:24

This question came from our site for professional and enthusiast programmers.

In the msdb database, there is a table named restorehistory:

declare @DB sysname = 'MyDB';
select * from msdb.dbo.restorehistory where destination_database_name = @DB;

This is a table that people with sufficient privileges can clear out, but if the restore was recent and you don't have a job which clears out this table (or if it hasn't run between then and now), you should be able to see the login which performed the restore.


You can also join it to a couple of other tables (if they have relevant data): backupset and backupmediafamily. If there are records there--with the same retention caveats as before--they'll tell you more about the backup file(s) used to restore:

declare @DB sysname = 'MyDB';
    rh.user_name, as backup_set_name,
    bs.user_name as backup_set_username,
    bs.database_name as backup_set_database_name,
    case bmf.device_type
        when 2 then 'Disk'
        when 5 then 'Tape'
        when 7 then 'Virtual Device'
        when 105 then 'Permanent backup device'
        else 'UNKNOWN'
    end as device_type_desc
    msdb.dbo.restorehistory rh
    left outer join msdb.dbo.backupset bs on rh.backup_set_id = bs.backup_set_id
    left outer join msdb.dbo.backupmediafamily bmf on bs.media_set_id = bmf.media_set_id
    rh.destination_database_name = @DB;

That way, you could also filter on device type or file location.

share|improve this answer

Backup and restore histories for SQL Server 2008 are stored in the msdb database restorehistory table. You can query it like so:

  FROM [msdb].[dbo].[restorehistory]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.