SQL Server Error 1126 Table Error Page Test Failed
In this article
SQL Server Error 1126 occurs when a database page test fails, specifically indicating a slot offset error. This is a critical sign of data corruption where the internal pointers within a data page (the slot array) no longer align with the actual row data on that page. To resolve this, you must identify the corrupted table or index and either rebuild the index or restore the affected data from a clean backup to ensure data integrity.
What You'll Need
- SQL Server Management Studio (SSMS) with administrative access.
- A recent, healthy full database backup.
- Access to the SQL Server Error Log.
- Sufficient disk space to perform index rebuilds or database restores.
Step-by-Step
- Identify the Scope of Corruption: The first step is to determine exactly which database and object are affected. Open SQL Server Management Studio (SSMS) and run the
DBCC CHECKDBcommand. This command checks the logical and physical integrity of all the objects in the specified database. Use the following syntax:DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;. The output will list the specific Page ID and the Object ID associated with the slot offset error. - Analyze the Error Log: Navigate to the Management folder in SSMS, expand SQL Server Logs, and open the current log. Search for "Error 1126". The log often provides the specific Page ID and the file ID where the failure occurred. This confirms whether the error is isolated to a single page or if there is a broader pattern of corruption across the storage subsystem.
- Determine if the Corruption is in a Non-Clustered Index: If the
DBCC CHECKDBoutput indicates that the error is located in a non-clustered index, the fix is straightforward. Non-clustered indexes are redundant copies of data used for performance. You can simply drop and recreate the index, or use theALTER INDEX REBUILDcommand. This process wipes the corrupted page and regenerates the index from the base table (the clustered index or heap), which effectively clears the slot offset error. - Address Corruption in the Clustered Index or Heap: If the error is in the clustered index (the actual data pages), rebuilding the index may not work because the source data itself is corrupted. In this scenario, the safest and most reliable method is to restore from a backup. If you have a full backup and subsequent transaction log backups, you can perform a page-level restore. This allows you to restore only the specific corrupted page (identified by the Page ID from Step 1) without taking the entire database offline.
- Perform a Page-Level Restore: Ensure your database is in the Full recovery model. Use the
RESTORE DATABASE ... PAGE = 'FileID:PageID'command. This targets only the corrupted slot offset page. After the page restore, you must apply all transaction logs since the backup to bring the page up to the current state of the rest of the database. - Verify the Fix: Once the index has been rebuilt or the page restored, run
DBCC CHECKDB ('YourDatabaseName')again. Ensure that the output reports zero allocation errors and zero consistency errors. If the error persists, the corruption may be deeper than a single page, requiring a full database restore.
Common Mistakes
One of the most common mistakes is attempting to use DBCC CHECKDB with the REPAIR_ALLOW_DATA_LOSS option as a first resort. This command can fix the slot offset error by simply deleting the corrupted rows. While this makes the error message go away, it results in permanent data loss without telling you exactly which records were deleted. Always attempt a backup restore or a non-clustered index rebuild before resorting to repair options that delete data.
Another frequent error is ignoring the underlying cause. Error 1126 is rarely a random software glitch; it is typically a symptom of hardware failure, such as a failing disk sector, a faulty RAID controller, or memory corruption. If you fix the page but do not investigate the hardware, the corruption will likely return in a different table or index shortly after.
Some administrators mistakenly believe that restarting the SQL Server service will clear the error. Because this is a physical corruption of the data on the disk, a service restart only clears the memory buffer; once the page is read from the disk again, the slot offset error will reappear.
Tips
To prevent this error in the future, implement a strict checksum policy. Ensure that the PAGE_VERIFY option for your database is set to CHECKSUM. This tells SQL Server to calculate a checksum for every page written to disk and verify it when the page is read. While this doesn't prevent corruption, it allows SQL Server to detect it immediately, preventing the corrupted data from being written back to the disk and potentially spreading the corruption.
Regularly schedule DBCC CHECKDB to run during maintenance windows. Detecting a slot offset error early—when it affects only one page—makes the recovery process much simpler (via page restore) than discovering it months later when the corruption has spread to multiple tables.
Maintain a rigorous backup strategy. A combination of weekly full backups, daily differential backups, and hourly transaction log backups ensures that you can recover from a Page 1126 error with minimal data loss.
Troubleshooting
If DBCC CHECKDB continues to report the error after an index rebuild, check if the table is a heap (a table without a clustered index). Heaps are more susceptible to certain types of corruption. In this case, creating a clustered index on the table can sometimes force a reorganization of the data that clears the slot offset, but this is risky if the data is truly corrupted. The only guaranteed fix for a corrupted heap is a restore from backup.
If you cannot perform a page-level restore because you are in the Simple recovery model, your only option is to restore the entire database to a separate temporary instance. You can then script out the data from the healthy temporary database and use INSERT INTO ... SELECT or MERGE statements to replace the corrupted rows in the production database. This requires identifying the specific primary keys of the rows located on the corrupted page.
If the error occurs across multiple different databases on the same server, stop all write operations immediately. This is a strong indicator of a failing storage array or a faulty system memory module (RAM). Contact your hardware vendor to run diagnostic tests on the physical disks and the motherboard's memory slots.
Frequently Asked Questions
What exactly is a slot offset error?
In SQL Server, each 8KB page has a slot array at the end of the page that acts as a map, pointing to the start of each row on that page. A slot offset error means the pointer in this array is pointing to a location that does not align with the start of a valid row, making the data unreadable.
Can I fix Error 1126 without a backup?
If the corruption is in a non-clustered index, yes, you can rebuild the index. If the corruption is in the clustered index or a heap, you can use REPAIR_ALLOW_DATA_LOSS, but this will delete the corrupted data. Without a backup, you cannot recover the lost records.
Does this error mean my hardware is failing?
It is a strong possibility. While software bugs can cause corruption, slot offset errors are frequently caused by "bit rot" or "torn pages" resulting from hardware malfunctions in the disk subsystem or RAM.
How long does DBCC CHECKDB take to run?
The duration depends on the size of your database and the speed of your disks. For very large databases, it can take hours. It is recommended to run it during low-traffic periods or on a restored backup copy of the database to avoid impacting production performance.
Will a database shrink operation fix this?
No, shrinking a database will not fix a slot offset error. In fact, shrinking can sometimes exacerbate corruption by moving pages around and potentially writing corrupted data into new locations.
Is the database still usable while this error exists?
The database remains online, but any query that attempts to read the specific corrupted page will fail with Error 1126. This means some users may experience crashes or errors while others, who are accessing different pages, see no issues at all.