This guide provides a script to retrieve the last restore date and time for each database in SQL Server. It’s particularly helpful for tracking restore operations or verifying backups during disaster recovery scenarios.
The script below queries the sys.databases
and dbo.restorehistory
system tables to get the most recent restore details for each database.
If a database wasn’t created via a restore (e.g., created manually or during SQL Server installation), the restore_date
column will return NULL. In such cases, this script may not provide meaningful results.
Here’s the SQL script:
Restore Types: The restore_type
column indicates the restore operation type:
> D: Full backup restore
> L: Transaction log restore
> I: Differential restore
Refer to MS Docs for detailed column descriptions.
For more great information on MSSQL backups, checkout my database backup & recovery tag!
Leave a Reply