Troubleshooting Guide: SQL Server Error 5226 — UNLINKEDREORGPAGE Deallocation Failure
Why This Error Happens
Error 5226 occurs when SQL Server’s DBCC CHECKDB repair process (typically REPAIR_ALLOW_DATA_LOSS) encounters a page marked as UNLINKED_REORG_PAGE that cannot be removed from the allocation structures because its linkage in the IAM (Index Allocation Map) or PFS (Page Free Space) pages is inconsistent or corrupted. This usually stems from underlying physical corruption caused by storage subsystem failures, improper shutdowns, or disk I/O errors that occurred during a previous index reorganization or page split operation. In most cases, this is a symptom of deeper database corruption rather than an isolated, standalone issue.
Step-by-Step Resolution Guide
Step 1: Confirm the Scope of Corruption
- Run
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGSto get a full list of errors, not just Error 5226. - Check the SQL Server error log (via SSMS or
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) for correlating I/O or storage warnings around the time corruption began. - Note the specific Page ID and File ID referenced in the error (
%d:%d) for targeted investigation.
Step 2: Rule Out Hardware and Storage Issues
- Check Windows Event Viewer (Event IDs 7, 9, 11, 15, 51, 129) under System logs for disk controller or storage driver errors.
- If using virtualized storage (Hyper-V/Azure), verify the underlying VHDX or storage pool integrity using
Repair-VirtualDiskor your SAN vendor’s diagnostic tools. - Ensure Windows Server 2025 storage drivers and firmware are fully updated before proceeding with repairs.
Step 3: Restore From a Known Good Backup (Preferred Method)
- If a recent, uncorrupted full backup exists, restore the database instead of repairing in place:
RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabaseName.bak' WITH REPLACE, RECOVERY- Apply any available transaction log backups to minimize data loss.
- This avoids forced data loss inherent to
REPAIR_ALLOW_DATA_LOSS.
Step 4: Run Repair Only if No Backup Is Available
- Set the database to single-user mode:
ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE- Execute the repair command:
DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS)- Return the database to multi-user mode:
ALTER DATABASE YourDatabaseName SET MULTI_USER- Note: this operation can delete the affected unlinked page and any associated rows, so expect potential data loss on the impacted table.
Step 5: Rebuild Affected Indexes
- After repair, rebuild all indexes on the table associated with the corrupted page to ensure structural integrity:
ALTER INDEX ALL ON YourTableName REBUILD- This resolves any residual fragmentation or orphaned allocation entries left behind by the repair process.
Alternative or Verification Steps
- Re-run
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGSafter remediation; a clean result with zero allocation or consistency errors confirms the fix. - If corruption recurs shortly after repair, treat it as a hardware-level issue — run
chkdsk /f /ron the underlying volume and consult your storage vendor, as this points to a failing disk or controller rather than a SQL Server defect.