Site icon Database Tutorials

SET LOCK_TIMEOUT and @@LOCK_TIMEOUT Function in SQL Server(TSQL)

 

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:

 

Exit mobile version