// SQL Server error reference

SQL Server error 824: Logical consistency-based I/O error

A page read from disk failed SQL Server's checks (bad checksum, torn page, wrong page ID). This is database corruption: run DBCC CHECKDB now.

Error number
824
Severity
24
Category
Corruption and I/O
Error message
SQL Server detected a logical consistency-based I/O error: %ls. It occurred during a %S_MSG of page %S_PGID in database ID %d at offset %#016I64x in file '%ls'. Additional messages in the SQL Server error log or operating system error log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see https://go.microsoft.com/fwlink/?linkid=2252374.

What it means

SQL Server verifies each page as it reads it, using the page checksum (or torn-page detection) and the page header. Error 824 means the read itself succeeded but the content is wrong: the data on disk is damaged. It is a severity 24 error, written to the error log, and the page is recorded in msdb.dbo.suspect_pages. The usual cause is the storage stack (disk, controller, drivers, SAN), not SQL Server.

Common causes

  • Faulty disks, controllers, firmware or storage drivers writing or returning bad data.
  • Power loss or a storage failure in the middle of a write without write-through protection.
  • File system filter drivers (antivirus, backup tools) interfering with database files.
  • Memory errors on the server corrupting pages before they were written.

How to fix it

  1. Run a full consistency check to see the extent of the damage.

    DBCC CHECKDB (N'SalesDb') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  2. See which pages were flagged.

    SELECT * FROM msdb.dbo.suspect_pages;
  3. The safe fix is restoring from backup. With the full recovery model and an unbroken log chain you can restore just the damaged pages.

    RESTORE DATABASE SalesDb PAGE = '1:57' FROM DISK = N'D:\Backup\SalesDb.bak' WITH NORECOVERY;
    -- then restore subsequent log backups, back up the tail of the log, and restore it WITH RECOVERY
  4. Check the storage: Windows event logs, hardware diagnostics, firmware and driver versions. Corruption comes back if the cause isn't fixed.

  5. DBCC CHECKDB ... REPAIR_ALLOW_DATA_LOSS is a last resort when no backup exists, because it deletes whatever it can't repair.

Questions

Is error 824 a SQL Server bug?

Almost never. SQL Server is reporting that the page it read doesn't match what it wrote, which points to the I/O path: storage hardware, drivers or filter drivers.

Related errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.