Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1128 Table Error Page Row Test Failed

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server Error 1128 occurs when a page-level consistency check (usually during DBCC CHECKDB) fails because the row checksum or the page verification test failed. This indicates physical or logical corruption within the database file, meaning the data written to the disk does not match what the system expects to see when reading it back. To resolve this, you must identify the corrupted table, attempt to recover the data via backups, or use repair options as a last resort to maintain database stability.

What You'll Need

  • Administrative access to the SQL Server instance (sysadmin role).
  • SQL Server Management Studio (SSMS) or a similar query tool.
  • The most recent full database backup and subsequent transaction log backups.
  • Sufficient disk space to perform a database restore or create a temporary copy of the database.

Step-by-Step

  1. Identify the Scope of Corruption: Start by running a comprehensive check to see exactly how many pages are affected. Open a new query window in SSMS and execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;. This command scans the entire database for consistency errors. Review the output in the Messages tab. Look specifically for the Error 1128 entry, which will tell you the database ID, the object ID (the table or index), and the specific page number that failed the row test.
  2. Locate the Affected Object: Once you have the object ID from the previous step, you need to know which table is causing the problem. Use the following query: SELECT OBJECT_NAME(object_id) AS TableName FROM sys.objects WHERE object_id = [YourObjectID];. Replace [YourObjectID] with the number provided in the error message. This confirms whether the corruption is in a base table or a non-clustered index.
  3. Determine if the Error is in an Index: If the corruption is located in a non-clustered index, the fix is straightforward because the data exists in the clustered index (the table itself). You can simply drop and recreate the affected index. If the error is in the clustered index (the table), the actual data rows are corrupted, and you must move to the recovery steps.
  4. Attempt a Page-Level Restore: If you have a full backup and transaction logs, the safest way to fix Error 1128 without losing data is a page restore. This allows you to restore only the corrupted page rather than the whole database. Use the RESTORE DATABASE [YourDatabaseName] PAGE = 'FileID:PageID' FROM BACKUP = 'YourBackupPath'; command. This keeps the rest of the database online while the specific corrupted page is replaced.
  5. Perform a Data Export (The Manual Save): If page restore is not an option and you suspect only a few rows are corrupted, try to copy the healthy data to a new table. Run SELECT * INTO Table_Backup FROM OriginalTable WHERE [PrimaryKey] NOT IN (SELECT [PrimaryKey] FROM OriginalTable WHERE [CorruptedColumn] IS NULL);. Note that if the corruption is severe, the SELECT statement may fail as soon as it hits the corrupted page. If it fails, you will need to use a range-based approach (e.g., WHERE ID BETWEEN 1 AND 1000) to isolate and skip the corrupted rows.
  6. Execute Repair Options (Last Resort): If backups are unavailable, you may have to use DBCC CHECKDB with repair options. First, set the database to single-user mode: ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;. Then, try REPAIR_REBUILD, which is safe and does not delete data. If that fails, you may be forced to use REPAIR_ALLOW_DATA_LOSS: DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);. Warning: This option will delete the corrupted pages to make the database structurally sound, meaning you will lose any data stored on those pages.
  7. Return to Multi-User Mode: After the repair is complete, return the database to its normal state: ALTER DATABASE [YourDatabaseName] SET MULTI_USER;.
  8. Verify the Fix: Run the initial check again: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS;. Ensure that no Error 1128 or related consistency errors remain in the output.

Common Mistakes

  • Running REPAIR_ALLOW_DATA_LOSS immediately: Many administrators jump straight to the most aggressive repair option. This is a critical mistake because it permanently deletes data. Always attempt a page restore or a manual data export first.
  • Ignoring the Error Log: Users often look only at the SSMS output and ignore the SQL Server Error Log. The log often contains hardware-level warnings (like I/O errors) that indicate the corruption is caused by a failing hard drive, not a software glitch.
  • Forgetting Single-User Mode: Attempting to run repair commands while the database is in multi-user mode will result in an error stating that the database is in use. You must explicitly set it to SINGLE_USER.
  • Not Verifying Backups: Assuming a backup is healthy without running RESTORE VERIFYONLY can lead to a situation where the restore fails after the original database has already been altered or damaged further.

Tips

  • Enable Page Verification: To catch these errors earlier, ensure your database is set to CHECKSUM page verification. You can check this with SELECT name, page_verify_enabled_extensions FROM sys.databases;. Setting this to CHECKSUM helps SQL Server detect corruption the moment a page is written or read.
  • Schedule Regular Consistency Checks: Do not wait for an application crash to find Error 1128. Schedule a weekly DBCC CHECKDB maintenance task to identify corruption while you still have recent backups available.
  • Check Hardware Logs: If you see frequent 1128 errors, check the Windows Event Viewer under System logs for "Disk" or "ntfs" errors. This usually points to a failing RAID controller or a bad sector on the physical disk.
  • Use Read-Only Copies: When attempting to salvage data from a corrupted table, perform the operations on a restored copy of the database rather than the production instance to avoid further corruption.

Troubleshooting

If the DBCC CHECKDB command hangs or fails to complete, the corruption may be so severe that the engine cannot even scan the pages. In this case, try running the check with the PHYSICAL_ONLY option: DBCC CHECKDB ('YourDatabaseName', PHYSICAL_ONLY);. This skips the logical checks and only looks for hardware-level page corruption, which is faster and less resource-intensive.

If you encounter an error stating that the database cannot be set to SINGLE_USER mode because of active connections, use the ROLLBACK IMMEDIATE clause. This forcibly disconnects all users. If that still fails, stop the SQL Server service entirely, restart it, and immediately run the ALTER DATABASE command before other applications can reconnect.

If REPAIR_ALLOW_DATA_LOSS does not clear the error, it is possible that the corruption exists in the system tables or the transaction log. If the log is corrupted, you may need to perform an emergency mode recovery: ALTER DATABASE [YourDatabaseName] SET EMERGENCY; followed by ALTER DATABASE [YourDatabaseName] SET SINGLE_USER; and then the repair command. This forces the database to ignore the log and focus on the data pages.

Frequently Asked Questions

What exactly is a row test failure?

A row test failure occurs when SQL Server performs a checksum validation on a data page and finds that the calculated value does not match the stored checksum. This means the bits on the disk have changed due to hardware failure, power loss, or driver bugs.

Can Error 1128 be caused by a software bug?

While rare, software bugs in the storage driver or the OS kernel can cause write-misalignment. However, the vast majority of these cases are caused by failing disk sectors, faulty RAM, or unexpected power shutdowns that leave a page partially written (torn pages).

Will rebuilding indexes fix the data corruption?

Only if the corruption is in a non-clustered index. If the corruption is in the clustered index (the actual table data), rebuilding the index will either fail with the same Error 1128 or it will simply copy the corrupted data into a new index structure, leaving the error intact.

Is it safe to ignore Error 1128 if the application is still working?

No. Corruption is often "silent" until a specific row is accessed. Ignoring it allows the corruption to potentially spread or result in a total database crash during a backup or a critical query, making recovery much harder later.

How does Page Restore differ from a Full Restore?

A full restore replaces the entire database, taking the whole system offline for the duration of the process. A page restore only replaces the specific 8KB pages that are corrupted, allowing the rest of the database to remain online and accessible to users.