Determine when a Restore took place

  • Is there a quick SQL I can run to see when the most recent RESTORE of a DB took place?

     

    Thanks

  • you can query restorehistory table in msdb database.

    for example:

    select max(restore_date)

    from msdb.dbo.restorehistory

    where destination_database_name='pubs'

  • You can check the following sql also which tells about the backups.

    SELECT  B.NAME, ISNULL(STR(ABS(DATEDIFF(DAY, GETDATE(),

     MAX(BACKUP_FINISH_DATE)))), 'NEVER') 'DAYS - THE BACKUP IS DONE' ,

     ISNULL(CONVERT(CHAR(10), MAX(BACKUP_FINISH_DATE), 101), 'NEVER') 'DATE- ON WHICH THE BACKUP WAS DONE'

     FROM MASTER.DBO.SYSDATABASES B LEFT OUTER JOIN MSDB.DBO.BACKUPSET A

     ON A.DATABASE_NAME = B.NAME AND A.TYPE = 'D' GROUP BY B.NAME ORDER BY B.NAME

  • Thanks...

    We have an App that requires the user to Restore a DB from us and merge it with what they already have - monthly.  I can check our logs to see when the App was run - but needed to know if the Restore happened before or after running our App.

    Thanks...

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply