title: An unexpected file id was encountered. File id 15 was expected but 14 was read from "..."
body: <p>Please help!</p>
  
  <p>I restarted a server where SQL SERVER 2012 is running on this morning. After the server was back, I found one user database were in "Recovery Pending" status in MS SQL Server Management Studio.</p>
  
  <p>In SQL log, I found the error msg: </p>
  
  <p>Error: 5161, Severity: 16, State: 1.</p>
  
  <p>An unexpected file id was encountered. File id 15 was expected but 14 was read from "\SQL-Server\DATA\15 Thumbdrive\DB\0014_TSf.ndf". Verify that files are mapped correctly in sys.master_files. ALTER DATABASE can be used to correct the mappings.</p>
  
  <p>Error: 5105, Severity: 16, State: 1.</p>
  
  <p>A file activation error occurred. The physical file name '\SQL-Server\DATA\15 Thumbdrive\DB\0014_TSf.ndf' may be incorrect. Diagnose and correct additional errors, and retry the operation.</p>
  
  <p>I checked in sys.master_files, and got results as below:</p>
  
  <pre><code>database_id  file_id  name        physical_name
  5            14       0013_TSf    \\SQL-Server\DATA\Test_\DB\0013_TSf.ndf
  5            15       0014_TSf    \\SQL-Server\DATA\15 Thumbdrive\DB\0014_TSf.ndf
  </code></pre>
  
  <p>From the result, the file '\SQL-Server\DATA\15 Thumbdrive\DB\0014_TSf.ndf' does have an id 15, not 14 as stated in the error message.</p>
  
  <p>I tried to remove this file from the user database but couldn't because it's in "Recovery Pending" which means the database is not online at all.</p>
  
  <p>I also tried to update sys.master_files or sys.sysbrickfile, but it didn't work, either, giving an error like "Ad hoc updates to system catalogs are not allowed".</p>
  
  <p>Any idea will be appreciated!</p>