Usecase: MSSQL Database is hosted in the cloud, I download the database thrue FTP and restore it on-premise automatically for reporting.
Now I want to retrieve the date/time when the backup was made, from the restored database, to show my users how old the data is that they are working with.
In my local MSDB, I only see when the database was restored, not when it was originally back-upped in the cloud. I know the date-time is in the .bak, but that is hard to query.
Any suggestions?
Best Answer
Answer from author's comment converted to community wiki
In case the original MSDB is not available, or backup history has been purged, the data is available within backup headers. Use
RESTORE HEADERONLY
to retrieve the header contents. In the header, there's about 60 pieces of metadata; refer to the Microsoft documents for detailed description.For example,