Troubleshooting Guide: SQL Server Error 3860 – “Cannot upgrade database ID 32767”
Why This Error Happens
Database ID 32767 is hard-reserved internally by the SQL Server engine for system snapshot operations (such as those used during DBCC CHECKDB) and is never meant to be assigned to a user database. This error typically surfaces during a version upgrade (e.g., migrating to SQL Server 2025) when the upgrade process detects a database, a snapshot, or orphaned metadata entry that has been incorrectly mapped to this reserved ID — often due to an improperly closed internal snapshot from a previous DBCC operation, a corrupted system catalog, or a failed prior upgrade attempt. Because the engine refuses to overwrite or reassign this protected ID, the upgrade process halts to prevent further catalog corruption.
Step-by-Step Resolution Guide
Step 1: Identify the Conflicting Database or Snapshot
- Connect to the instance using SQLCMD or SSMS in single-user mode if necessary:
sqlcmd -S . -E -N - Run
SELECT name, database_id, source_database_id FROM sys.databases WHERE database_id = 32767;to check for an orphaned entry. - Check for leftover internal snapshots using
SELECT * FROM sys.databases WHERE source_database_id IS NOT NULL;
Step 2: Clear Orphaned Internal Snapshots
- If a stale DBCC CHECKDB internal snapshot is found, it generally indicates a previous CHECKDB operation terminated abnormally (e.g., Windows Server 2025 crash or forced service restart).
- Restart the SQL Server service cleanly via PowerShell:
Restart-Service -Name MSSQLSERVER -Force - Re-run
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;on the affected database to force SQL Server to clean up any dangling internal snapshot handles.
Step 3: Repair System Catalog Corruption
- If the orphaned ID persists after a clean restart, boot the instance into single-user mode using
NET START MSSQLSERVER /m"SQLCMD". - Run
DBCC CHECKDB('master') WITH NO_INFOMSGS, ALL_ERRORMSGS;to validate the master database catalog itself isn’t corrupted. - If corruption is confirmed in
master, restoremasterfrom a known-good backup taken before the issue began, located typically atC:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\.
Step 4: Retry the Upgrade Process
- Exit single-user mode and restart the SQL Server 2025 setup wizard or run the command-line upgrade:
Setup.exe /ACTION=Upgrade /INSTANCENAME=MSSQLSERVER /IACCEPTSQLSERVERLICENSETERMS - Monitor the Summary log file in
%ProgramFiles%\Microsoft SQL Server\160\Setup Bootstrap\Log\for Error 3860 recurrence.
Alternative or Verification Steps
- Verify the fix by querying
sys.databasespost-upgrade to confirm no entries exist withdatabase_id = 32767and that the upgraded database’s compatibility level matches SQL Server 2025 (160). - If the error persists after catalog repair, detach the affected user database, rename its physical
.mdf/.ldffiles, and re-attach it to a fresh instance usingCREATE DATABASE ... FOR ATTACHto force SQL Server to regenerate a clean, non-conflicting database ID.