SQL Server Error 1127: Fix Table Error Page Test Failed
In this article
SQL Server error 1127 ("Table error: page %S_PGID failed test... values are ...") is a corruption error reported by DBCC CHECKDB. It means a data page in a table or index does not match the structure SQL Server expects, typically because of disk or I/O problems. The fix is to restore the affected database (or filegroup) from a known good backup; repair options exist but usually cause data loss and should be a last resort. This guide walks through confirming the error, identifying the damaged object, and getting the database healthy again.
What You'll Need
- sysadmin access to the SQL Server instance, or db_owner rights on the affected database
- SQL Server Management Studio (SSMS) or another tool that can run T-SQL
- Access to your most recent verified database backups
- Permission to take the database offline or into single-user mode briefly, if a repair or page restore is required
Step-by-Step
- Confirm the error. Run
DBCC CHECKDB ('YourDatabase') WITH NO_INFOMSGS, ALL_ERRORMSGS;and look for messages starting with "Table error" containing "failed test" with values listed after it. Note the page IDs and object IDs reported. - Save the full output. Capture the complete DBCC output to a file (in SSMS, use Results to File, or run
DBCC CHECKDB ('YourDatabase') WITH ALL_ERRORMSGSfrom a sqlcmd session redirected to a text file). You will need it to decide what to restore and to report to storage or hardware vendors. - Check the underlying hardware and system logs. Error 1127 almost always comes from I/O problems. Review the Windows System event log for disk errors and the SQL Server error log for messages like 823, 824, or 825. If storage is failing, fix or replace it first — restoring onto a bad disk will corrupt the data again.
- Identify the damaged object. The DBCC output usually names the table or index. If it only gives an object ID, run
SELECT OBJECT_NAME(object_id);with the reported ID, or useDBCC PAGEdetails from the output, to map page IDs to the affected table or index. - If the damage is only in a nonclustered index: you can simply drop and recreate that index. Check the DBCC output — if it says the index is rebuildable or lists only a nonclustered index, drop it with
DROP INDEX IndexName ON TableName;and recreate it from your index definition script. Then rerun CHECKDB to confirm the error is gone. - If table data pages are damaged, restore from backup. The safest fix is restoring the database from the most recent clean backup. Verify the backup with
RESTORE VERIFYONLY FROM DISK = N'C:\Backups\YourDatabase.bak' WITH CHECKSUM;before restoring. - Restore just the damaged pages if you can. If your backups were taken with CHECKSUM and you have a full backup plus an unbroken chain of log backups, page restore is the least disruptive option:
RESTORE DATABASE YourDatabase PAGE = '1:1234,1:5678' FROM DISK = N'C:\Backups\YourDatabase.bak' WITH NORECOVERY;then restore all subsequent log backups in order withWITH NORECOVERYand finish withRESTORE LOG ... WITH RECOVERY;. Only the damaged pages go offline; the rest of the database stays readable. Run CHECKDB afterwards. - Repair only as a last resort. If no usable backup exists,
DBCC CHECKDB ('YourDatabase', REPAIR_ALLOW_DATA_LOSS);can make the database consistent, but as the name says it will deallocate damaged pages and lose the rows on them. The database must be in single-user mode:ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE;run the repair, thenALTER DATABASE YourDatabase SET MULTI_USER;Export whatever you can salvage before repairing, and rerun CHECKDB to confirm consistency. - Verify and document. After any fix, run
DBCC CHECKDB ('YourDatabase') WITH NO_INFOMSGS;until it completes with no errors. Take a fresh full backup immediately, and record what caused the corruption so it does not recur.
Common Mistakes
- Running REPAIR_ALLOW_DATA_LOSS before trying a restore. Repair should never be the first move when a good backup exists.
- Restoring or repairing on failing hardware without fixing the disk, controller, or driver problem first — the corruption comes back.
- Restoring log backups out of order or skipping one after a page restore, which breaks the recovery chain.
- Forgetting to take a fresh full backup after the repair, leaving the repaired database unprotected.
- Ignoring earlier 823/824/825 messages in the error log; those are the warning signs that preceded the 1127 error.
Tips
- Enable
BACKUP CHECKSUMand run periodicDBCC CHECKDBjobs so corruption is caught while good backups still exist. - If only a nonclustered index is damaged, dropping and recreating it is fast and loses nothing — always check for this before restoring.
- Page-level restore keeps the database online apart from the damaged pages, which matters on production systems.
- Use
WITH NO_INFOMSGSon CHECKDB in monitoring jobs so real errors are not buried in informational noise. - Keep the full DBCC output; if you open a Microsoft support case or a storage vendor ticket, they will want it.
Troubleshooting
DBCC CHECKDB will not complete: Check for a lack of tempdb space — CHECKDB uses tempdb heavily on large databases and can fail with errors about tempdb. Add tempdb files or space and rerun.
RESTORE VERIFYONLY reports the backup is unreadable: Fall back to an older full backup and its log chain. Keep multiple generations of backups for exactly this situation.
Page restore fails because the backup lacks CHECKSUM: Page restore requires checksummed backups. Use a full database restore instead, or accept the repair option.
Error 1127 returns after a restore: The storage layer is almost certainly still faulty. Involve your storage or hardware vendor, check RAID status, firmware, and antivirus filter drivers, and move the database files to known-good storage before restoring again.
Cannot switch to single-user mode: Other sessions are connected. Roll back their transactions with WITH ROLLBACK IMMEDIATE, or kill the offending sessions, then retry the ALTER DATABASE statement.
Frequently Asked Questions
What does error 1127 actually mean?
DBCC CHECKDB found a page that failed one of its structural tests — the "values are" part lists the expected and actual values that did not match. It is a physical corruption indicator, usually caused by I/O problems.
Is my database safe to use while error 1127 exists?
No. Queries touching the damaged pages may fail or return wrong results, and the damage can spread. Take the database read-only or restrict access until it is repaired or restored.
Will DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS always work?
It usually makes the database logically consistent, but it deletes damaged pages and the data on them. Some corruption patterns cannot be repaired at all, in which case restoring from backup is the only option.
Can I fix just one page instead of the whole database?
Yes — page-level restore works if your backups were created with CHECKSUM and you have the complete log backup chain after the full backup containing the good page.
How can I prevent error 1127 in the future?
Maintain healthy storage (monitor RAID and disk errors), keep drivers and firmware current, exclude database files from aggressive antivirus scanning, use checksummed backups, and run scheduled DBCC CHECKDB jobs.
Does this error mean my disk is definitely failing?
Usually something in the I/O path is at fault — disk, controller, firmware, drivers, or memory — but the SQL Server error log messages (823/824/825) and Windows event logs are what pinpoint the actual cause. Review them before replacing hardware.