title: SQL-Server: Error - Logical file is not part of database. Use RESTORE FILELISTONLY to list the logical file names
body: <p>I made a script to restore .bak or backup files. It works for some databases, but not for one. How do I make it work for any type of .bak file ? This is in sql server 2008. 
  The error message is - </p>
  
  <pre><code>Msg 3234, Level 16, State 1, Line 1
  Logical file 'Northwind_Data' is not part of database 'Northwind'. 
  Use RESTORE FILELISTONLY to list the logical file names.
  Msg 3013, Level 16, State 1, Line 1
  RESTORE DATABASE is terminating abnormally.
  </code></pre>
  
  <p>Script - </p>
  
  <pre><code>IF DB_ID('Northwind') IS NULL
  BEGIN
  RESTORE DATABASE [Northwind]
  FILE = N'Northwind_Data'
  FROM 
  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SS2008\MSSQL\Backup\Northwind.bak'
  WITH  FILE = 1,
  MOVE N'Northwind_Data'
  TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SS2008\MSSQL\DATA\Northwind.mdf',
  MOVE N'Northwind_Log'
   TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SS2008\MSSQL\DATA\Northwind_0.LDF',
  NOUNLOAD,  STATS = 10
  END
  </code></pre>