title: How can I retrieve the logical file name of the database from backup file
body: <p>I was looking into the steps of how to <a href="http://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/">Restore Database Backup using SQL Script (T-SQL)</a>. Here are the steps:</p>
  
  <blockquote>
    <p>Database <code>YourDB</code> has full backup <code>YourBackUpFile.bak</code>. It can be restored using following two steps:</p>
    
    <p><strong>Step 1:</strong> Retrieve the logical file name of the database from the backup.</p>
  
  <pre><code>RESTORE FILELISTONLY
  FROM DISK = 'D:BackUpYourBackUpFile.bak'
  GO
  </code></pre>
    
    <p><strong>Step 2:</strong> Use the values in the <code>LogicalName</code> column in the following step.</p>
  
  <pre><code>----Make Database to single user Mode
  ALTER DATABASE YourDB
  SET SINGLE_USER WITH
  ROLLBACK IMMEDIATE
  
  ----Restore Database
  RESTORE DATABASE YourDB
  FROM DISK = 'D:BackUpYourBackUpFile.bak'
  WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
  MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'
  </code></pre>
  </blockquote>
  
  <p>I am just having problem on how to get the <code>YourMDFLogicalName</code> and <code>YourLDFLogicalName</code>.
  Can any one help me with that?</p>