SQL Server Admin
T-SQL Articles

March 22, 2009

Retrieve information about Database Restore for all Databases in SQL Server 2005/2008




If you want to find out details like when were all the databases last restored along with some more information like who restored it, recovery model etc., use the msdb..restorehistory and msdb..backupset tables as shown below:


SELECT rh.destination_database_name, rh.user_name, bk.first_lsn,


rh.restore_date, bk.backup_start_date, bk.recovery_model


FROM msdb..restorehistory rh


INNER JOIN msdb..backupset bk ON rh.backup_set_id = bk.backup_set_id


WHERE rh.destination_database_name IN


(SELECT name from sys.sysdatabases)


AND bk.type = 'D'




Output:


destination_database_name    user_name    first_lsn    restore_date    backup_start_date    recovery_model


Northwind    Suprotim-PC\Suprotim    41000000016800052    2009-03-14 17:58:36.653    2009-03-14 17:58:18.000    SIMPLE




The msdb..backupset is a very useful table and you can also get important details like the LSN (Log Sequence Number) used for a differential backup set.


Did you like this post?
kick it on DotNetKicks.com
subscribe via rss subscribe via e-mail
print this post follow me on twitter



 
  Feedback:

comments

0 Responses to "Retrieve information about Database Restore for all Databases in SQL Server 2005/2008"
 

Copyright © 2009-2011 All Rights Reserved for SQLServerCurry.com by Suprotim Agarwal | Terms and Conditions