With SET LOCK_TIMEOUT, we can set the maximum amount of time a session will wait to access a blocked resource in milliseconds. If a query waits until this time in the session, the query will be canceled and it will return the information about cancel process.
With the @@LOCK_TIMEOUT function, we can query the LOCK_TIMEOUT setting of the corresponding session.
If @@LOCK_TIMEOUT is not set for a session, it will return -1 when we query @@LOCK_TIMEOUT.
We can use SET LOCK_TIMEOUT and @@ LOCK_TIMEOUT as follows:
1 2 3 4 5 |
SELECT @@LOCK_TIMEOUT AS [@@LOCK_TIMEOUT] GO SET LOCK_TIMEOUT 1000 GO SELECT @@LOCK_TIMEOUT AS [@@LOCK_TIMEOUT] |