Sql-server – Attempt to fetch logical page (5:65424) in database 2 failed

corruptionsql serversql-server-2008

I am getting the following SqlException on calling a stored procedure:

Attempt to fetch logical page (5:65424) in database 2 failed. It belongs to allocation unit 7349876362857938944 not to 4899918190390149120.

System.Data.SqlClient.SqlException occurred
Message="Attempt to fetch logical page (5:65424) in database 2 failed. It belongs to allocation unit 7349876362857938944 not to 4899918190390149120.

Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=21
LineNumber=257
Number=605
Procedure="ispDisplayCount"
Server="10.10.1.1"
State=3

What does this exception mean? Is there any resolution to the above issue?

Although the database referenced in the error above indicates tempdb, similar errors referencing Message 605, may be fixed using the answers below.

Msg 605, Level 21, State 3, Line 1
Attempt to fetch logical page (1:8687634) in database 7 failed. It belongs to allocation unit 72057594364821504 not to 72057594052476928.

Best Answer

If the database ID indicated by the error message is 2, the database affected is tempdb. One method for fixing this type of corruption in tempdb is to simply restart the SQL Server instance. For database ID's other than 2, follow the recommendations below.

You may need to restore from backup, however try this:

As a member of the sysadmin role, execute DBCC PAGE (2, 5, 65424, 3); and look for the Metadata: IndexId value.

  • If it is 0 (heap) or 1 (clustered index) you need to restore from backup.
  • If it is not 0 or 1, you can just rebuild the non-clustered index.

Run the DBCC command, and let us know what you find. Check https://www.mssqltips.com/sqlservertip/1578/using-dbcc-page-to-examine-sql-server-table-and-index-data/ for details about the DBCC PAGE command