Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2005
SET (Transact-SQL)
 SET LOCK_TIMEOUT (Transact-SQL)
Community Content
In this section
Statistics Annotations (1)
Collapse All/Expand All Collapse All
SQL Server 2005 Books Online (November 2008)
SET LOCK_TIMEOUT (Transact-SQL)

Specifies the number of milliseconds a statement waits for a lock to be released.

Topic link icon Transact-SQL Syntax Conventions

SET LOCK_TIMEOUT timeout_period
timeout_period

Is the number of milliseconds that will pass before Microsoft SQL Server returns a locking error. A value of -1 (default) indicates no time-out period (that is, wait forever).

When a wait for a lock exceeds the time-out value, an error is returned. A value of 0 means to not wait at all and return a message as soon as a lock is encountered.

At the beginning of a connection, this setting has a value of -1. After it is changed, the new setting stays in effect for the remainder of the connection.

The setting of SET LOCK_TIMEOUT is set at execute or run time and not at parse time.

The READPAST locking hint provides an alternative to this SET option.

CREATE DATABASE, ALTER DATABASE, and DROP DATABASE statements do not honor the SET LOCK_TIMEOUT setting.

Requires membership in the public role.

The following example sets the lock time-out period to 1800 milliseconds.

SET LOCK_TIMEOUT 1800
GO
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Timeout units are incorrect      Pete R ... Thomas Lee   |   Edit   |   Show History
The timeout value is seconds, not milliseconds. The example given would set a timeout of 1800 seconds, which is of course effectively forever and therefore useless.
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker