Smart Systems for Home

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

SQL Server Error 592: Fix "Cannot Find ID" Fast

· 8 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

Error 592 in SQL Server means the engine was handed an object, page, or allocation reference it cannot resolve: "Cannot find ITEM in database ID" (or the related "No item found" wording for an allocation unit or object ID). It is almost always a symptom of metadata inconsistency inside a database rather than a user mistake, so the fix is to confirm the error text, identify the object it names, check the database for corruption with built-in consistency tools, and only then repair or restore. The shortest working path is: capture the full error, run DBCC CHECKDB on the affected database, and act on its output. Do not run repair options before you have a fresh, verified backup.

What You'll Need

  • Access to SQL Server Management Studio (SSMS) or Azure Data Studio with a login in the sysadmin role on the instance, or server-level permissions to run DBCC CHECKDB.
  • The full text of the error, including the object ID, index ID, partition ID or allocation unit number it names. Error 592 messages usually include these numbers.
  • A recent, verified backup of the affected database. Test-restore it somewhere else before you repair anything.
  • Free disk space on the server equal to roughly the size of the database plus room for the log, because DBCC CHECKDB and repairs need temp space and similar log space.
  • The exact database name. If the error does not name it, you will need to find it through the error log or the affected application.
  • In SQL Server Management Studio (SSMS) with a login in the sysadmin role on the instance
  • The full text of the error, including the object, page, or allocation unit it names
  • A current, verified backup of the database

Menu labels and messages can differ slightly by SQL Server version, edition and region, and the tool is different on Azure SQL Database or Azure SQL Managed Instance, where you cannot run many DBCC commands against a user database.

Step-by-Step

  1. Capture the complete error. Do not work from a truncated message. Copy the full text from the application, event log or SSMS Messages tab. It typically reads like Msg 592, Level 16, State 1, Line X: Cannot find ITEM in database ID N or No item found with matching keys.... Find the line in Windows Event Viewer under Windows Logs > Application where the SQL Server source sits, or read the SQL Server error log in SSMS under Management > SQL Server Logs. The database ID will be a number; you will need it in a later step.
  2. Turn the database ID into a name. Run SELECT DB_NAME(N); in a new query window, replacing N with the number from the message. If it returns NULL, the database no longer exists on that instance, which itself explains the error: a stale reference (often from a dropped database, an old job, or a scheduled task) is pointing at something that is gone. That is a code or job problem, not a corruption problem, and fixing the reference is enough.
  3. Note what the error was doing. Write down the query, job, application action, or maintenance task that produced the error. A monthly index rebuild, a backup job, or a particular reporting query tells you where to look next. If the error appears during a backup, the backup is failing, not the database read: check the destination and the drive before assuming corruption.
  4. Identify the object if one is named. If the message includes an object ID, run SELECT OBJECT_NAME(object_id); with that number. A result means the object still exists and you can focus there. A NULL result means the object is gone but something still references it, which points to a drop that left residue or a stale dependency.
  5. Check the instance health first. Look at the SQL Server error log for entries around the same time, especially messages about I/O errors, "SQL Server has encountered N occurrence(s) of I/O requests taking longer than 15 seconds", or suspicious page checksums. I/O-related messages suggest the storage layer, and no DBCC repair will fix a failing disk. In that case stop and involve whoever manages the server or storage.
  6. Run a consistency check. Open a query window against the affected database and run DBCC CHECKDB (database_name) WITH NO_INFOMSGS, ALL_ERRORMSGS; Use the actual database name, not the ID. On a large database this can take a long time and can load the server, so run it in a maintenance window, or against a restored copy of the database on another instance if one exists. Using a copy is the safer option because it proves whether the corruption is real and gives you room to experiment.
  7. Read the output carefully. If CHECKDB reports no errors, the database is consistent and the 592 error is coming from outside it: a stale reference, an object that was dropped and recreated, a mismatch between names and IDs in application code, or a SQL Server component older or newer than the metadata it is reading. In that case go to the Troubleshooting section. If CHECKDB reports corruption, continue to the next step.
  8. Take a fresh backup before any repair. Run BACKUP DATABASE database_name TO DISK = 'path.bak' WITH CHECKSUM; and, if possible, restore it to another instance to confirm it is usable. Repairs are not reversible. If the backup fails, that failure is itself information and you will likely need to restore from your last known-good backup instead.
  9. Repair with the least aggressive option first. Try DBCC CHECKDB (database_name, REPAIR_FAST) WITH NO_INFOMSGS; only if CHECKDB said the database has errors and you have the backup. Each level up is riskier. Repair can drop pages or objects to make the database consistent, and whatever it drops is lost. It can also change data and pages in ways you cannot undo.
  10. Escalate to a restore if repair does not work. If repair fails or the damage is in critical tables, restore the last good backup onto the affected database and apply any transaction logs or differentials you have. You lose everything written after that backup, which is why step 8 matters. If you have no usable backup and the database is badly damaged, stop and get an experienced DBA or the vendor of the application involved before attempting more repair runs.
  11. Validate after repair. Run DBCC CHECKDB (database_name) WITH NO_INFOMSGS; again. Because repair may have dropped objects, also run DBCC CHECKCATALOG (database_name) WITH NO_INFOMSGS; and compare object counts, application health checks and any row counts you recorded before repair. Repair dropping an index or a non-clustered index page is a common outcome; recreate the index if needed.

Common Mistakes

  • Running REPAIR_ALLOW_DATA_LOSS first. It is the most destructive option. Use the least aggressive repair and only after a verified backup.
  • Running DBCC CHECKDB against the wrong database because the error showed a number, not a name. Translate the ID first.
  • Repairing a mirrored or Always On database in place. Prefer restoring or repairing a copy and letting HA handle the switch.
  • Ignoring I/O errors in the error log and treating the problem as pure metadata corruption.
  • Assuming the error means the database is gone. Often the database ID no longer exists and a stale scheduled job, agent task or application connection string is the real culprit.

Tips

  • Run DBCC CHECKDB regularly on a known-good schedule, not only when an error appears. It catches problems early.
  • Save the full CHECKDB output to a file so you can compare before and after repair.
  • Work on a restored copy first whenever size and resources allow it. You can run repair experiments there without risking production.
  • Keep copies of the error text, database names, object IDs and the date and time, in case you need to escalate.

Troubleshooting

  • CHECKDB says the database is clean but the error persists. The reference is stale. Check for jobs under SQL Server Agent in SSMS, application connection strings, synonyms and views that refer to an old object, and any code that builds SQL from cached IDs. Recreate the objects or update the references.
  • CHECKDB cannot run. If you lack permissions it may fail with a permission error. If temp space runs out, free space and retry. On Azure SQL Database, many DBCC repair options are not available to you; use point-in-time restore or open a support case instead.
  • Repair fixes the error but the application misbehaves. Repair can drop pages and objects. Check for missing indexes, compare object counts, and look for tables that no longer return expected rows. Restore from backup if the loss is unacceptable.
  • The error appears only at backup time. Check the backup destination and disk, then retry the backup to a different location. A failing destination can surface as metadata errors.
  • The error appears in a mirror of the database copy. If you find a corrupt object in a restored copy but not in production, clean it in the copy, then plan the restore or repair on production during a maintenance window.

Frequently Asked Questions

What causes SQL Server error 592?

It means SQL Server was given an object, page, or allocation reference it cannot resolve in the named database. Typical causes are metadata or page corruption, a dropped object that something still references, a stale database ID in a job or application, or a damaged backup destination.

Is error 592 always corruption?

No. It can come from stale references to objects or databases that no longer exist. Run DBCC CHECKDB first to find out which kind of problem you have before considering a repair.

Can I fix error 592 without a backup?

Only if it is a stale reference you can safely remove or correct. If CHECKDB shows corruption, do not repair without a backup. Without one, get an experienced DBA and your application's vendor involved first.

Does DBCC REPAIR solve error 592?

Sometimes, but it is not the first step. Use REPAIR_FAST only after CHECKDB reports errors and you have a verified backup, and remember that repair can drop data and objects.

Why does the message only show a database ID?

The message names the database by ID. Run SELECT DB_NAME(n); to turn the number into a name before you do anything else.