A database holds data nobody expected, a refresh is said to have run last night, or an audit wants to know when production was last overwritten. The first fact to pin down is when the database was last restored, and msdb records it for every database on the instance.
This is not about backup schedules or restore progress. It is one historical check, and the query below runs it in one go.
LastRestoreDate for each database. A database with no row has no restore on record here. Check the restore type before trusting the newest row, because a verify-only job leaves a V row too.Show Last Restore Date and Time for Each Database
The query below returns the most recent restore date for each database recorded in msdb.dbo.restorehistory.
-- get database last restore time
SELECT
[rs].[destination_database_name] AS [DatabaseName],
[rs].[restore_date] AS [LastRestoreDate]
FROM
msdb..restorehistory rs
INNER JOIN
(SELECT
[destination_database_name],
MAX([restore_date]) AS [last_restore_date]
FROM
msdb..restorehistory
GROUP BY
[destination_database_name]) AS [max_rs]
ON
[rs].[destination_database_name] = [max_rs].[destination_database_name]
AND [rs].[restore_date] = [max_rs].[last_restore_date]
ORDER BY
[rs].[destination_database_name];
This query returns the most recent restore event recorded for each database.

Why Last Restore Time Matters
Checking restore history is useful when:
- Investigating unexpected data changes
- Validating recent recovery activity
- Confirming whether a restore actually completed
- Reviewing activity on inherited or shared environments
A restore leaves a footprint. This query helps you find it.
Important Notes and Limitations
A few things to be aware of:
- Databases that were never restored will not appear
- Databases created manually may not have restore history
- Restore history can be lost if system databases are rebuilt
- This does not show restore progress or duration
If you need to know how long a restore that is running right now will take, that is a different query entirely: Get Backup and Restore Progress reads sys.dm_exec_requests for the live percentage and estimated finish.
Understanding Restore Types
Restore history includes different restore operations:
D, full database restoreI, differential restoreL, transaction log restoreFandG, file and filegroup restoresV,RESTORE VERIFYONLY, which checks the backup and restores nothing
Each restore event is logged separately. The query above only returns the most recent restore per database, regardless of type, so a V row from a verify job can be the newest entry for a database nobody has actually restored.
Final Thoughts
Restore history is easy to overlook, but it often explains more than expected.
When troubleshooting data issues or validating recovery actions, knowing when a database was last restored can save a lot of guesswork.
This is a simple check, but it earns its place in baseline DBA tooling.
Frequently Asked Questions
The newest row is a RESTORE VERIFYONLY from the backup check job. How do I ignore it?
restore_type in the inner query, so the MAX is taken over real restores only: add WHERE restore_type <> 'V' before the GROUP BY, and the same filter to the outer msdb..restorehistory so the join cannot pick the verify row back up. Everything else (D, I, L, and F or G for file and filegroup restores) is a real restore.Which backup was it restored from, and from which server?
restorehistory.backup_set_id to msdb.dbo.backupset: database_name and server_name there are the source, and backup_start_date is how old the data was when it came back. Get Last Restore History does that join for you and lists every restore per database rather than only the latest.A database was restored, but it is not in the list.
msdb on the instance that ran the restore, when the restore completes. A restore still running has no row yet, and a failed restore never gets one, so for a restore in flight read Get Backup and Restore Progress instead. If the database was restored or seeded on another replica, the row is in that instance’s msdb, not this one.Related
Knowing when the last restore happened is usually the first of a few questions. These answer the rest.
- DBA Scripts: Get Last Restore History, every restore per database with its type, source file and LSNs, not only the latest.
- Database Cannot Be Opened, It Is in the Middle of a Restore, when the last restore never finished and the database is stuck in RESTORING.
- Get Last Database Backup Times in SQL Server, the other half of the question, do we have backups to restore from.
- DBA Scripts: Get Backup Chain Integrity, whether the chain you would restore from has any gaps.
- DBA Scripts: The Complete Guide, every script on the site in one place.
Leave a Reply