Troubleshooting Guide: SQL Server Error 5094
Why This Error Happens
Error 5094 occurs because SQL Server 2025 blocks certain operations—such as dropping a database, changing its file structure, or restoring over it—when one or more database snapshots exist against it. This restriction also applies when an active DBCC CHECKDB internal snapshot or replica is still being used for consistency checking. Essentially, SQL Server refuses to proceed because it detects dependent snapshot objects that must be removed first to avoid data corruption or orphaned snapshot files.
Step-by-Step Resolution Guide
Step 1: Identify Existing Database Snapshots
- Open SQL Server Management Studio (SSMS) and connect to the instance.
- Run the following query to list all snapshots tied to the source database:
SELECT name, database_id, source_database_id
FROM sys.databases
WHERE source_database_id = DB_ID('YourDatabaseName');
- Note the names of any returned snapshot databases, as these must be removed before proceeding.
Step 2: Drop the Database Snapshots
- For each snapshot identified in Step 1, run:
DROP DATABASE [YourDatabaseName_Snapshot01];
- Repeat this command for every snapshot listed in the query results.
- Avoid dropping the source database itself—only target the snapshot copies.
Step 3: Check for Active DBCC CHECKDB Processes
- Open Activity Monitor in SSMS or run
sp_who2to check for long-running sessions. - Look specifically for sessions executing
DBCC CHECKDB,DBCC CHECKTABLE, orDBCC CHECKFILEGROUP, as these create hidden internal snapshots (visible in theTEMPDBor source directory) while running. - If an active replica is found, allow the DBCC process to complete naturally rather than killing the session abruptly, as forcing termination can leave orphaned snapshot files on disk.
Step 4: Retry the Original Operation
- Once all snapshots are dropped and no active DBCC sessions remain, retry the original command (e.g.,
DROP DATABASE,RESTORE DATABASE, orALTER DATABASE). - Ensure you are using a sysadmin or db_owner role account to avoid permission-related failures during the retry.
Alternative or Verification Steps
- Verify the fix: Re-run the query from Step 1 against
sys.databases; if it returns zero rows for thesource_database_id, the database is clear of snapshots and the operation should now succeed. - Alternative solution: If the error persists despite no visible snapshots, restart the SQL Server service (via services.msc or
net stop/start MSSQLSERVER) during a maintenance window to clear any lingering internal DBCC snapshot handles that haven’t been released from memory.