How to fix Error 1126 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 1126 — Table Error, Page %S_PGID, Test Failed, Slot %d

Why This Error Happens

Error 1126 occurs when SQL Server’s DBCC consistency checker detects that a page-level structure test has failed on a specific slot within a database page, indicating physical or logical corruption. This is typically caused by underlying storage issues such as faulty disk sectors, improper shutdowns, SAN/storage controller firmware bugs, or corruption introduced during I/O operations (bit flips, torn pages) that bypassed SQL Server’s page checksum protections. It can also surface after an unclean failover in an Always On Availability Group or after restoring a backup that was already corrupted at the source.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to get the full list of affected objects, pages, and slots.
  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) and Windows Event Viewer (Application log) for correlating I/O or disk warnings (Event ID 823, 824, or 825).
  • Note the exact table, index, and page ID (%S_PGID) referenced in the error to determine if corruption is isolated to a non-clustered index (easier fix) or clustered data (harder fix).

Step 2: Rule Out and Fix Underlying Hardware/Storage Issues

  • Run chkdsk D:\ /f /r (replace D:\ with your actual SQL data drive) to scan for and repair physical disk errors.
  • Check Windows Server 2025 Storage Spaces or SAN management console for any reported virtual disk health alerts.
  • Verify disk firmware and HBA/RAID controller drivers are up to date, as outdated drivers are a common cause of torn-page writes.

Step 3: Restore From a Clean Backup (Preferred Method)

  • Identify the last known good full backup taken before the corruption timestamp using RESTORE HEADERONLY FROM DISK = 'E:\Backups\YourDB.bak';
  • Perform a restore with recovery: RESTORE DATABASE YourDatabaseName FROM DISK = 'E:\Backups\YourDB.bak' WITH REPLACE, RECOVERY;
  • Apply any subsequent transaction log backups in sequence to minimize data loss up to the point of failure.

Step 4: Use DBCC CHECKDB Repair as a Last Resort

  • Put the database in single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; — understand this may delete the corrupted rows/pages entirely.
  • Return the database to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 5: Rebuild Affected Indexes

  • If corruption was isolated to a non-clustered index, drop and rebuild it instead of running a destructive repair: ALTER INDEX ALL ON YourTableName REBUILD;
  • This avoids data loss since non-clustered indexes can be fully regenerated from the clustered index/heap.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; after remediation — a clean run with zero allocation or consistency errors confirms the fix.
  • If corruption recurs after repair, engage your storage/hardware vendor for diagnostics, as repeated Error 1126 strongly indicates a persistent hardware-level fault rather than a SQL Server defect.