Folks,
Assume you receive a disconnected backup of a SQL Server database (2005 or 2008) and you restore that to your SQL Server instance.
Is there a way, is there a system catalog or something, to find out when the last write operation occured on that particular database? I'd like to be able to find out what day a particular database backup was from - unfortunately, that's not really being recorded explicitly anywhere, and checking all dozens of data table for the highest date/time stamp isn't really an option either....
Any ideas? Sure - I can look at the date/time stamp of the *.bak file - but can I find out more precisely from within SQL Server (Management Studio) ??
Thanks! Marc
If you have access to the SQL Server instance where the backup was originally run, you should be able to query
msdb
:There are several table relating to backup sets:
By querying these tables you can determine when the last backups occurred, what type of backups occurred and where the files were written to.
A bit late, but should be what you want.
Each write to the database is an entry in the log file. Which has an LSN. This must be stored in the backup for log restores at least.
So, how to match LSN to a datetime?
I've never used this before (just had a play for this answer). Some writes are very likely part of the backup itself, but you should be able to distinguish them with some poking around.
as far as I know in the master database there exists a Log-table where every write is stored with detailed information. BUT I'm unsure if you need to enable the Log-mechanism - so that the default is not to log and you have to enable it. In Oracle for example it is the way around there exists a system-database table Log that you can query.
If that is not the case - you could still write yourself a trigger and apply that on every table/column needed and do the logging yourself.
You can try
RESTORE HEADERONLY
on your backup file, as described herethat should give you the information you're looking for.