How can I get the database name from the bakup file

  • Thread starter Thread starter Bruce Lee
  • Start date Start date
B

Bruce Lee

I want to get the backup set name from a database backup file. How can I do?

Thanks,
Bruce
 
You might want to check out RESTORE HEADERONLY and RESTORE FILELISTONLY in
BooksOnLine.
 
You can use restore headeronly - e.g.
restore headeronly
from disk = 'C:\YourBackup.bak'
You can find more info in books online.

-Sue
 
Thanks Andrew and Sue. The Restore Headeronly works well.
But is it possible to get the name from the SQLDMO classes?

Thanks,
Bruce
 
Yes.

Take a look at ReadBackupHeader Method of the Restore object in BOL / MSDN.
It gives a QueryResults set.

- Tim
 
Back
Top