Here is a question that updates a value inward the Northwind Shippers tabular array using TABLOCK:
----------
Use Northwind
GO
UPDATE Shippers
WITH (TABLOCK)
SET CompanyName='Speedy Gonsalez'
WHERE ShipperID=1
--
SELECT * from Shippers
------------
The question updates the cite of the transportation companionship whose ID=1 to a novel name. When TABLOCK is used inward the inward a higher house trend it should endure inside the parenthesis.
Read this recommendation from Microsoft:
"An UPDATE controversy e'er acquires an exclusive (X) lock on the tabular array it modifies, in addition to holds that lock until the transaction completes. With an exclusive lock, no other transactions tin alter data. You tin specify tabular array hints to override this default demeanour for the duration of the UPDATE controversy past times specifying only about other locking method, however, nosotros recommend that hints endure used solely every bit a concluding resort past times experienced developers in addition to database administrators"
TABLOCK is i of several tabular array hints inward SQL Server which includes the following:
FORCESCAN
FORCESEEK
HOLDLOCK
NOLOCK
NOWAIT
PAGLOCK
READCOMMITTED
READCOMMITTEDLOCK
READPAST
READUNCOMMITTED
REPEATABLEREAD
ROWLOCK
SERIALIZABLE
SNAPSHOT
SPATIAL_WINDOW_MAX_CELLS = integer
TABLOCK
TABLOCKX
UPDLOCK
XLOCK
Table hints tin endure used amongst whatsoever of the next operations:
Applies to:
DELETE
INSERT
SELECT
UPDATE
MERGE
Komentar
Posting Komentar