Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If you have (say) 10 transaction log backups and some, all or none may have been restored to the database. Is there a way to determine which files have already been restored?

share|improve this question
up vote 1 down vote accepted

You will want to match up the first/last lsn from running RESTORE HEADERONLY FROM DISK = N'E:\PathToBackup\test.trn' WITH NOUNLOAD

With the LSN info from dbcc log (mydb)

The LSN from the dbcc command needs to be converted to be usable however. For example, if you have an LSN from the dbcc log command that looks like 00000014:00000157:0003 you would need to do the following:

left(convert(int, 0x00000014) * 1000000, 6) +
right(convert(int, 0x00000157) + 1000000, 6) +
right(convert(int, 0x0003) + 1000000, 5)

Note: There is a little bit of debate out there about how to convert this properly, and the solution above is a bit of a hack. The best way is with the UDF in this KB article.

share|improve this answer
Fantastic! This looks like exactly what I need – David Hayes Oct 15 '10 at 15:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.