SET LOCK_TIMEOUT allows an application to set the maximum time that a statement waits on a blocked resource. When a statement has waited longer than the LOCK_TIMEOUT setting, the blocked statement is automatically canceled, and an error message is returned to the application.
At the beginning of a connection, @@LOCK_TIMEOUT returns a value of -1.
Syntax of @@LOCK_TIMEOUT Function :
@@LOCK_TIMEOUT
Return type of @@LOCK_TIMEOUT function is integer.
Examples of @@LOCK_TIMEOUT Function :
Example 1 : Use of @@LOCK_TIMEOUT function in select clause
SELECT @@LOCK_TIMEOUT
Output
-1
Above example returns -1 as LOCK_TIMEOUT variable is not set.
Example 2 : Use of @@LOCK_TIMEOUT function after setting LOCK_TIMEOUT variable value in select clause
SET LOCK_TIMEOUT 3600
SELECT @@LOCK_TIMEOUT
Output
3600
Above example returns 3600 milliseconds, as we have set LOCK_TIMEOUT variable to 3600 and then execute @@LOCK_TIMEOUT function.