Many a times we need to get the details of what is in the database backup device before we do a database restore for e.g. if we have to move the files to new location we need to know the logical database file names contained in the backup device. This is done by SQL Server restore filelistonly command. The query is very simple and is shown below
RESTORE FILELISTONLY FROM DISK='e:\ahmad\Adventureworks2014.bak' WITH FILE=1
The output of the above query is shown below.
If a database device contains more than one database backups specify the backup number using FILE=1/2/3/…n. It returns lot more useful information however I have particularly found useful the logicalname and physicalName of the database in the backup device. To get complete details refer to http://msdn.microsoft.com/en-us/library/ms173778.aspx
Happy learning!!!
Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook