December 14, 2017 at 3:25 pm
Hi,
Is there any difference b/w 1 and 2 below?
1) INSERT MyTable WITH (TABLOCKX) ...
2) INSERT dbo.[project] WITH (TABLOCK, XLOCK) ...
Thanks!
December 14, 2017 at 4:04 pm
Accordingly with the official documentation there is no difference:
TABLOCK
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.XLOCK
Specifies that exclusive locks are to be taken and held until the transaction completes. If specified with ROWLOCK, PAGLOCK, or TABLOCK, the exclusive locks apply to the appropriate level of granularity.TABLOCKX
Specifies that an exclusive lock is taken on the table.
December 14, 2017 at 4:13 pm
Thank you Evgeny, but does it mean that
applying WITH (TABLOCKX) is exactly the same as WITH (TABLOCK, XLOCK) ?
December 14, 2017 at 6:46 pm
TABLOCKX is a shorter version of (TABLOCK, XLOCK).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply