How to Fix SQL Server Error 5228 (Msg 5228)
Disk or memory corruption in a table page triggers sql server error 5228 during checks. You fix it by restoring clean backups, rebuilding the damaged index, or running repair jobs. This message has a severity level of 16 in the database engine. It points to a broken row on a specific data page. Your team must act fast to stop further data loss across the storage system. What causes sql server error 5228 in the engine The engine logs this error when a consistency check finds a bad table row.
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Disk or memory corruption in a table page triggers sql server error 5228 during checks. You fix it by restoring clean backups, rebuilding the damaged index, or running repair jobs.
This message has a severity level of 16 in the database engine. It points to a broken row on a specific data page. Your team must act fast to stop further data loss across the storage system.
What causes sql server error 5228 in the engine
The engine logs this error when a consistency check finds a bad table row. The message lists the object ID, index ID, partition ID, and allocation unit ID. It also prints the allocation unit type, the page number, and the exact row number.
Failing hard drives or faulty storage controllers often cause this page damage. Bad memory chips can also corrupt a page before the server writes it to disk. Sometimes a sudden power loss stops a write job halfway through. When the database reads that broken row later, the check fails and throws the alert.
Because the severity is 16, the issue stays inside the affected user table. The rest of the database can still run normal queries on other tables. Still, any app that reads the broken page will hit a wall and fail.
How to check the damage without extra risk
Before you touch the broken table, you should check the full scope of the damage. Many teams make the mistake of giving every engineer full admin rights during an outage. The fixed owner role can run all maintenance tasks, and it can drop the database. You cannot change the rights assigned to fixed database roles on the server.
Instead, let most engineers look at the problem with safe read rights. A database user is the identity of a login when it connects to a database. For access to one or a few databases, a contained user is an option. An admin must first enable contained databases on the server and the database. Members of the fixed data reader role can read all data from user tables. This lets your team check unaffected rows while one lead plans the real fix.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
How to fix the corrupted table and page safely
Start by checking your system hardware logs for disk or memory errors. If the disk is still failing, any repair you run will break again right away. Move the database files to healthy storage before you try to fix the table.
Next, look at the index ID listed in the error message. If the index ID is greater than one, the damage is in a nonclustered index. You can drop and rebuild that index to clear the error without losing any data.
If the index ID is zero or one, the base table data is broken. The safest fix is to restore the single broken page from a clean backup. You then apply your transaction log backups to bring that page up to date. Permitted row (unless row-level security applies) stays intact, and you do not lose recent work.
If you have no clean backup, you must copy out the good rows first. Set up a new table and read all healthy pages into it. Avoid the last-resort repair modes unless you accept permanent data loss on that page. Those modes simply delete the broken page to make the table pass the check.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server, inline in the TDS wire protocol. On every batch an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a batch hits the server, hoop.dev guardrails refuse disallowed actions with a native TDS error or hold risky statements for approval. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns in memory, and every decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Does sql server error 5228 take the whole database offline?
No, this error has a severity of 16 and affects only the damaged page. Queries that do not read that specific page or row will still run fine.
Can I fix this error by restarting the database server?
No, a restart will not fix broken data that is already written to the disk. You must restore from a backup or rebuild the affected index to clear it.
How can I tell which table has the broken row?
Look at the object ID printed in the error message text. You can query the system catalog views to match that ID to a table name.
Related guides
In this post