LOCK_TIMEOUT
Milliseconds a statement waits for a lock before failing with error 1222; -1 waits forever.
- Predeterminado
-1 (wait forever)- Range
- -1, 0 (do not wait), or 1 to 2147483647 ms
- Restart needed
- No
- Default checked on
- SQL Server 2025
Lo que hace
A session setting (SET LOCK_TIMEOUT), not a server option. The statement fails but the transaction stays open unless XACT_ABORT is on. SQL Server has no server-wide statement timeout; command timeouts are set by the client driver (30 seconds in ADO.NET).
Valor predeterminado
-1 (wait forever). -1 (SQL Server 2025).
Check the current value
SELECT @@LOCK_TIMEOUT;
Change it
SET LOCK_TIMEOUT 5000; -- 5 seconds, this session
No restart; applies to the current session from the next statement.
When to change it
In migration scripts and admin jobs, so DDL fails fast instead of waiting in the lock queue and blocking users behind it.
What can go wrong
The application must handle error 1222 and decide whether to roll back.
The closest setting on other engines
| Motor | Ajuste | Predeterminado | Restart |
|---|---|---|---|
| SQL Server |
LOCK_TIMEOUT this page
|
-1 (wait forever) |
No |
| PostgreSQL |
lock_timeout
|
0 (disabled) |
No |
| MySQL |
innodb_lock_wait_timeout
|
50 |
No |
| SQLite |
busy_timeout
|
0 |
No |
Questions about LOCK_TIMEOUT
What is the default value of LOCK_TIMEOUT in SQL Server?
-1 (wait forever). -1 (SQL Server 2025).
Does changing LOCK_TIMEOUT require a restart?
No. No restart; applies to the current session from the next statement.
When should I change LOCK_TIMEOUT?
In migration scripts and admin jobs, so DDL fails fast instead of waiting in the lock queue and blocking users behind it.
Back to all SQL Server settings, or check the SQL Server manual for every option.
Check LOCK_TIMEOUT on your own server
SQLly runs the query above against SQL Server and the other engines in this reference, from one desktop app on macOS, Windows and Linux.