Table-level Locks

Microsoft SQL Server can lock an entire table by using the SELECT…table_name (TABLOCK) statement. This performs the same operation as the Oracle LOCK TABLE…IN SHARE MODE statement. The lock allows others to read a table, but prevents them from updating it. By default, the lock is held until the end of the statement. If you also add the keyword HOLDLOCK (SELECT…table_name (TABLOCK HOLDLOCK)), the table lock is held until the end of the transaction.

An exclusive lock can be placed on a SQL Server table with the SELECT…table_name (TABLOCKX) statement. This statement requests an exclusive lock on a table. It is used to prevent others from reading or updating the table and is held until the end of the command or transaction. It is similar in function to the Oracle LOCK TABLE…IN EXCLUSIVE MODE statement.

SQL Server does not provide a NOWAIT option for its explicit lock requests.