A query or operation may fail with an error like the following when an invalid file ID is referenced by the SQL Server Engine:
Msg 5180, Level 22, State 1, Line 1
Could not open File Control Bank (FCB) for invalid file ID 255 in database 'mydb'. Verify the file location. Execute DBCC CHECKDB.
Since this error is severity 22, the user's session will be disconnected. This error message is written into the SQL Server ERRORLOG and the Windows Application Event Log with EventID = 5180.
The SQL Server Engine references a file ID in many different situations mostly when referencing a page id (since the file ID is the first portion of the page ID). If for any reason, the file ID being referenced is < 0 or is not a valid file ID in a database (per the valid file IDs listed in system catalog views such as sys.database_files), then a 5180 error can be encountered.
One possible cause is that a stored file ID is not valid. An example of this is a forwarded record. Since the forwarded record in a row references another page, when that page is accessed and the file ID is invalid, a 5180 error could be encountered. This condition would be a database corruption error on the page with the forwarded record. (In this example, DBCC CHECKDB would report Msg 8993).
Another example is an invalid file ID as part of a page ID as stored in the page header for a "next" or "prev" page ID. This field is used to link a series of pages such as in a clustered index. If the file ID is invalid for the prev or next page, when the engine must reference this to traverse to the next or previous page, a 5180 error can be encountered. (In this example, DBCC CHECKDB reports Msg 8981).
If the problem is not an invalid file ID due to a corrupted stored page ID, then the problem may be within the SQL Server Engine.
If you encounter this error, you should run DBCC CHECKDB against the database as listed in the error message. If you find errors, you should restore from a known good backup. If you cannot restore from a backup, then your other option is to use the repair option of DBCC CHECKDB as recommended by its output. In most cases, a repair of this type of error will result in a data loss. For more information about using CHECKDB and causes of database corruption problems see the article: How to troubleshoot database consistency errors reported by DBCC CHECKDB
If DBCC CHECKDB does not report any error and the problem continues to occur, you should contact Microsoft Technical Support for assistance. Be prepared to provide the query that is encountering the 5180 error. See the More Information section on how to determine what query encountered the error.
The File Control Block (FCB) is an internal memory structure that keeps track of important information about the file associated with the database. A file ID is used to uniquely identify a FCB for a database. If the server engine tries to reference a file ID that is invalid, the FCB structure cannot be located which triggers the 5180 error condition.
To find out what query encountered this error, you can use the following techniques:
Article ID: 2015747 - Last Review: 05/07/2014 07:21:00 - Revision: 3.0
1; var Route = "76500"; var Ctrl = ""; document.write("