Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Configuration FunctionsRSS Feeds

@@LOCK_TIMEOUT - LOCK_TIMEOUT fUNCTION

Posted By: Sarita Patel     Category: SQL Server     Views: 2918

This article explains about @@LOCK_TIMEOUT function in sql server with examples.

@@LOCK_TIMEOUT function is used to get current lock time-out settings in milliseconds for current session.

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.
  
Share: 


Didn't find what you were looking for? Find more on @@LOCK_TIMEOUT - LOCK_TIMEOUT fUNCTION Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of @@LOCK_TIMEOUT - LOCK_TIMEOUT fUNCTION is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!