Troubleshooting Guide: SQL Server Error 1124 – Table Error: Page %S_PGID Test Failed
Why This Error Happens
Error 1124 occurs when SQL Server’s consistency checker (DBCC CHECKDB) detects that a page structure on disk does not match the expected internal linkage, typically due to physical corruption of the database file. This corruption is most often caused by faulty disk I/O, storage controller errors, abrupt power loss, or a failing SSD/HDD sector that silently wrote bad data. It can also surface after improper VM snapshot restores or when antivirus software locks/modifies .mdf or .ndf files mid-write on Windows Server 2025.
Step-by-Step Resolution Guide
Step 1: Isolate the Database and Run Diagnostics
- Open SQL Server Management Studio (SSMS) or
sqlcmdand set the database to single-user mode:ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; - Run a full consistency check:
DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS; - Record the exact Page ID (%S_PGID) and Slot number reported in the output for reference.
Step 2: Verify Underlying Storage Health
- Check Windows Event Viewer under Windows Logs > System for Disk or Ntfs warnings (Event ID 7, 51, or 153) correlating with the SQL error timestamp.
- Run
chkdsk C: /f /r(or the relevant drive letter hosting the .mdf/.ldf files) via an elevated Command Prompt, scheduling a reboot if the volume is in use. - If using SAN/NAS storage, confirm there are no firmware or multipath driver alerts in Server Manager.
Step 3: Restore From a Clean Backup (Preferred Fix)
- Navigate to your backup repository (e.g.,
D:\SQLBackups\YourDB.bak) and verify backup integrity:RESTORE VERIFYONLY FROM DISK = 'D:\SQLBackups\YourDB.bak'; - Restore the database to a point before corruption occurred:
RESTORE DATABASE [YourDB] FROM DISK = 'D:\SQLBackups\YourDB.bak' WITH REPLACE, RECOVERY; - If no clean backup exists, proceed to repair as a last resort:
DBCC CHECKDB ('YourDB', REPAIR_ALLOW_DATA_LOSS);— note this may discard the corrupted row/page.
Step 4: Bring Database Back Online
- Set the database back to multi-user mode:
ALTER DATABASE [YourDB] SET MULTI_USER; - Monitor SQL Server error logs (
C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG) for recurrence of Error 1124 over the next 24–48 hours.
Alternative or Verification Steps
- Re-run
DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS;immediately after the fix — a clean result with zero allocation/consistency errors confirms resolution. - If corruption recurs on the same physical page/slot, treat it as a hardware fault: migrate the database files to a different volume/disk and run full vendor diagnostics (e.g., manufacturer SSD toolbox) on the original drive.