SQL Server error 992 means the instance could not obtain a shared lock on a database file, usually because another process is holding an incompatible lock or the file is locked at the operating-system level. The fastest fix is to identify the blocking session with sys.dm_tran_locks or sp_who2, stop the offending process if it is safe, and then retry the operation. If the lock is held outside SQL Server, close the program or service that has the file open and restart the SQL Server service.
This guide walks through the safe order of checks, from reading the error details to clearing the lock and preventing it from coming back. Labels in SQL Server Management Studio (SSMS) and in Windows tools can differ slightly by version, so treat menu names as a guide rather than an exact match.
What You'll Need
- A login with at least
VIEW SERVER STATEpermission (sysadmin or securityadmin is typical for this work). - SQL Server Management Studio (SSMS) connected to the affected instance, or
sqlcmdif you prefer the command line. - Administrative access to the Windows server if you need to restart the SQL Server service or use tools such as Resource Monitor or Process Explorer.
- The name of the database and, if possible, the file path mentioned in the error message.
Step-by-Step
- Read the full error text. Error 992 is often reported alongside a file name and a database name. Note both, because the file path tells you whether the problem is a data file (.mdf), a log file (.ldf), or a backup or restore target. The exact wording varies by SQL Server version, but the file path is the key detail.
- Check whether the operation is a backup, restore, or file-level change. Shared lock failures most often appear during
BACKUP DATABASE,RESTORE DATABASE,ALTER DATABASE, or when a database is being taken offline. If you triggered one of these, the lock may simply be held by an active transaction. Wait for the transaction to finish, then retry. - List blocking sessions. In SSMS, open a new query window against the instance and run:
SELECT request_session_id, resource_type, resource_description, request_mode, request_status FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID('YourDatabaseName');
Look for sessions with a mode such as Sch-M (schema modification) or X (exclusive) that are blocking your shared lock request. The session ID is the number you will act on. - Identify what those sessions are doing. Run
sp_who2or querysys.dm_exec_sessionsandsys.dm_exec_requeststo see the login, host, program, and current command for each session ID. This tells you whether the blocker is an application, a maintenance job, or a stray query window. - Stop the blocker safely. If the blocking session belongs to a known application or a query you started, close the application or cancel the query. If you must terminate it from SQL Server, use
KILL <session_id>;only after confirming that the session is not performing a critical write. Killing a session rolls back its transaction, which can take time and may affect application state. - Check for operating-system locks. If no SQL Server session is blocking but the error persists, the file may be locked by another process. Open Resource Monitor (press Windows+R, type
resmon, press Enter), go to the CPU tab, and use the Associated Handles search box to search for the file name. Close the program that owns the handle, or stop the related service if it is safe to do so. - Restart the SQL Server service if needed. If the handle belongs to SQL Server itself and no session explains it, restart the SQL Server service from SQL Server Configuration Manager or the Services console. Warn anyone using the instance first: restarting disconnects all sessions and rolls back in-flight transactions.
- Retry the original operation. Run the backup, restore, or database change again. If it succeeds, capture the session details from step 3 so you can identify the recurring blocker next time.
- Prevent recurrence. Schedule backups and index maintenance outside business hours, avoid long-running transactions that hold schema locks, and make sure antivirus exclusions cover SQL Server data, log, and backup folders where your security policy allows it. Antivirus scanning of database files is a common cause of file-level lock conflicts.
Common Mistakes
- Killing a session without checking what it is doing. A KILL on a large write transaction can cause a long rollback and delay recovery.
- Restarting SQL Server before checking for an external file handle. The restart may not clear a lock held by another program, and you lose the evidence.
- Ignoring the file path in the error. The path often shows whether the conflict is on a data file, a log file, or a backup destination on a network share.
- Assuming the error is always inside SQL Server. File-level locks from backup agents, antivirus, or file copy tools produce the same symptom.
- Running the diagnostic queries against the wrong database ID. Use
DB_ID('YourDatabaseName')so you filter to the affected database.
Tips
- Run the
sys.dm_tran_locksquery a few times in a row. A blocker that appears and disappears points to a short-lived job rather than a stuck session. - Record the login and program name of recurring blockers. That is usually enough to identify the application or scheduled task to adjust.
- For backup failures, confirm the backup destination is writable and not held open by another backup process.
- Keep a maintenance window for operations that need schema locks, such as index rebuilds, so they do not collide with user activity.
Troubleshooting
If the error returns immediately after you clear the lock, the blocker is likely a scheduled job or an application that reconnects and reacquires the lock. Check SQL Server Agent jobs and application connection pools, and reschedule the job or fix the application query that holds the lock.
If Resource Monitor shows the handle is owned by SQL Server but no session appears in sys.dm_tran_locks, the lock may be at the file-system level during a restore or file growth operation. Wait for the operation to finish, then retry. If the server is a failover cluster node, check cluster logs for file resource conflicts before restarting anything.
If the error occurs on a network share, verify that the SQL Server service account has read and write permissions on the share and that no other host has the file open. Network file locks are outside SQL Server's control, so the fix is on the file server side.
Frequently Asked Questions
What does error 992 actually lock?
It is a shared lock request on a database file resource. SQL Server needs that lock to read or coordinate access to the file, and another session or process is holding an incompatible lock.
Can I fix error 992 without restarting SQL Server?
Yes, in most cases. Finding and stopping the blocking session or the external process that holds the file handle usually clears it without a restart.
Is it safe to run KILL on the blocking session?
Only if you know what the session is doing. KILL rolls back the session's transaction, which can take time and may interrupt an application. Confirm the session details first.
Why does error 992 appear during backups?
Backups request shared locks on database files. If another operation holds a conflicting lock, or the backup destination file is locked by another process, the backup can fail with this error.
Does antivirus cause error 992?
It can. Real-time scanning of SQL Server data, log, or backup files can hold file handles. Add exclusions where your security policy permits, and test after any change.
Will restarting SQL Server always fix it?
No. A restart clears SQL Server's own sessions, but a lock held by another program or a network file server will survive the restart and the error will return.