|
1 | 1 | --- |
2 | 2 | title: "Table Hints (Transact-SQL) | Microsoft Docs" |
3 | 3 | ms.custom: "" |
4 | | -ms.date: "08/31/2017" |
| 4 | +ms.date: "04/21/2020" |
5 | 5 | ms.prod: sql |
6 | 6 | ms.prod_service: "database-engine, sql-database" |
7 | 7 | ms.reviewer: "" |
@@ -121,7 +121,7 @@ With some exceptions, table hints are supported in the FROM clause only when the |
121 | 121 | > [!IMPORTANT] |
122 | 122 | > Omitting the WITH keyword is a deprecated feature: [!INCLUDE[ssNoteDepFutureAvoid](../../includes/ssnotedepfutureavoid-md.md)] |
123 | 123 | |
124 | | -The following table hints are allowed with and without the WITH keyword: NOLOCK, READUNCOMMITTED, UPDLOCK, REPEATABLEREAD, SERIALIZABLE, READCOMMITTED, TABLOCK, TABLOCKX, PAGLOCK, ROWLOCK, NOWAIT, READPAST, XLOCK, SNAPSHOT, and NOEXPAND. When these table hints are specified without the WITH keyword, the hints should be specified alone. For example: |
| 124 | +The following table hints are allowed with and without the `WITH` keyword: `NOLOCK`, `READUNCOMMITTED`, `UPDLOCK`, `REPEATABLEREAD`, `SERIALIZABLE`, `READCOMMITTED`, `TABLOCK`, `TABLOCKX`, `PAGLOCK`, `ROWLOCK`, `NOWAIT`, `READPAST`, `XLOCK`, `SNAPSHOT`, and `NOEXPAND`. When these table hints are specified without the WITH keyword, the hints should be specified alone. For example: |
125 | 125 |
|
126 | 126 | ```sql |
127 | 127 | FROM t (TABLOCK) |
@@ -256,7 +256,7 @@ Is equivalent to READUNCOMMITTED. For more information, see READUNCOMMITTED late |
256 | 256 | > For UPDATE or DELETE statements: [!INCLUDE[ssNoteDepFutureAvoid](../../includes/ssnotedepfutureavoid-md.md)] |
257 | 257 | |
258 | 258 | NOWAIT |
259 | | -Instructs the [!INCLUDE[ssDE](../../includes/ssde-md.md)] to return a message as soon as a lock is encountered on the table. NOWAIT is equivalent to specifying SET LOCK_TIMEOUT 0 for a specific table. The NOWAIT hint does not work when the TABLOCK hint is also included. To terminate a query without waiting when using the TABLOCK hint, preface the query with `SETLOCK_TIMEOUT 0;` instead. |
| 259 | +Instructs the [!INCLUDE[ssDE](../../includes/ssde-md.md)] to return a message as soon as a lock is encountered on the table. NOWAIT is equivalent to specifying `SET LOCK_TIMEOUT 0` for a specific table. The NOWAIT hint does not work when the TABLOCK hint is also included. To terminate a query without waiting when using the TABLOCK hint, preface the query with `SETLOCK_TIMEOUT 0;` instead. |
260 | 260 |
|
261 | 261 | PAGLOCK |
262 | 262 | Takes page locks either where individual locks are ordinarily taken on rows or keys, or where a single table lock is ordinarily taken. By default, uses the lock mode appropriate for the operation. When specified in transactions operating at the SNAPSHOT isolation level, page locks are not taken unless PAGLOCK is combined with other table hints that require locks, such as UPDLOCK and HOLDLOCK. |
@@ -334,7 +334,7 @@ This option allows for fine-tuning of query execution time by adjusting the trad |
334 | 334 | TABLOCK |
335 | 335 | Specifies that the acquired lock is applied at the table level. The type of lock that is acquired depends on the statement being executed. For example, a SELECT statement may acquire a shared lock. By specifying TABLOCK, the shared lock is applied to the entire table instead of at the row or page level. If HOLDLOCK is also specified, the table lock is held until the end of the transaction. |
336 | 336 |
|
337 | | -When importing data into a heap by using the INSERT INTO \<target_table> SELECT \<columns> FROM \<source_table> statement, you can enable optimized logging and locking for the statement by specifying the TABLOCK hint for the target table. In addition, the recovery model of the database must be set to simple or bulk-logged. For more information, see [INSERT (Transact-SQL)](../../t-sql/statements/insert-transact-sql.md). |
| 337 | +When importing data into a heap by using the `INSERT INTO \<target_table> SELECT \<columns> FROM \<source_table>` statement, you can enable minimal logging and optimized locking for the statement by specifying the TABLOCK hint for the target table. In addition, the recovery model of the database must be set to simple or bulk-logged. The TABLOCK hint also enables parallel inserts. For more information, see [INSERT (Transact-SQL)](../../t-sql/statements/insert-transact-sql.md). |
338 | 338 |
|
339 | 339 | When used with the [OPENROWSET](../../t-sql/functions/openrowset-transact-sql.md) bulk rowset provider to import data into a table, TABLOCK enables multiple clients to concurrently load data into the target table with optimized logging and locking. For more information, see [Prerequisites for Minimal Logging in Bulk Import](../../relational-databases/import-export/prerequisites-for-minimal-logging-in-bulk-import.md). |
340 | 340 |
|
|
0 commit comments