News

Copyright © 2008-2018 Paula DiTallo

Tag Cloud



sql server: How can I list or review the last restores for all the databases on a server?

Go to the server your are interested in gathering the information from, then issue this statement:

WITH LastRestoresOnServer AS
(
SELECT
    sysdb.[name] as dbName,
    sysdb.[create_date],
    sysdb.[compatibility_level],
    sysdb.[collation_name],
    r.*,
   ROW_NUMBER() OVER (PARTITION BY sysDb.Name ORDER BY r.[restore_date] DESC) as RN
FROM master.sys.databases sysdb
LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = sysDb.Name
)
SELECT *
FROM [LastRestoresOnServer]
WHERE RN = 1

Monday, April 13, 2015 4:58 PM

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Comment:
Verification: