SQL: ALL_LATEST_FILES option for RESTORE

SQL: ALL_LATEST_FILES option for RESTORE

The default action when performing a backup is to append to the backup file yet the default action when restoring a backup is to restore just the first file. This has never made sense to me.

Apparent loss of data ?

I constantly come across customer situations where they are puzzled that they seem to have lost data after they have completed a restore. Invariably, it’s just that they haven’t restored all the backups contained within a single OS file.

This happens most commonly with log backups but also happens when they have not restored the most recent database backup file.

How to fix it

It is not trivial to achieve this within simple T-SQL scripts, when the number of backup files within the OS file is unknown. It really should be easy.

I’d like to see a FILES=ALL_LATEST_FILES (or similar) option on the RESTORE command. For RESTORE DATABASE, it should restore the most recent database backup plus any subsequent log files. For RESTORE LOG (which is the most important missing option), it should just restore all relevant log backups that are contained.

Would love to hear your thoughts because all the options that I think of are pretty messy and need dynamic SQL.

2026-05-10