Tuesday, August 30, 2011

How to see the list of files in a SQL server backup file?

How to see the list of files in a SQL server backup file?


Today I was coding one application which will help us to restore and take back of our application’s databases.While coding the application I came across a situation, where I need to now the logical file name of the mdf and ldf files in the backup file.I googled a loot and finally I found a solution which I thought of sharing here for other who needs the same.

The TSQL command below will show the show the back up type and other details of the file.


RESTORE HEADERONLY FROM DISK='E:\xxxxxxxxxxxxx'

 
To retrieve the logical files name and other details use the below TSQL

RESTORE FILELISTONLY FROM DISK = 'E:\xxxxxxxxxxxxx' with file=1

No comments:

Post a Comment