question

RajRam avatar image
RajRam asked

How to Know DB properties

Hi, How can we know that a database has been restored

a) From which database backup ?
b) On which date ?

Regards RajRam.

t-sqlrestoremeta-data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sp_lock avatar image
sp_lock answered

You can you the Backup/Restory table that SQL Server stores in the msdb database.

http://msdn.microsoft.com/en-us/library/ms188653%28SQL.90%29.aspx

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image
Fatherjack answered

I think this is what you need;

USE [msdb] 
go

SELECT
    [rs].[destination_database_name] ,
    [rs].[restore_date] ,
    [bs].[backup_start_date] ,
    [bs].[backup_finish_date] ,
    [bs].[database_name] AS [source_database_name] ,
    [bmf].[physical_device_name] AS [backup_file_used_for_restore]
FROM
    msdb..restorehistory rs
INNER JOIN msdb..backupset bs
ON  [rs].[backup_set_id] = [bs].[backup_set_id]
INNER JOIN msdb..backupmediafamily bmf
ON  [bs].[media_set_id] = [bmf].[media_set_id]
ORDER BY
    [rs].[restore_date] DESC

Courtesy of Thomas LaRock at http://www.mssqltips.com/tip.asp?tip=1860&ctc

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.