Hi ,
when begin transaction and update holds lock on row and no other can update if unless committed, why and what is the purpose of "WITH(ROWLOCK) " ?as per internet both looks same
UPDATE transak WITH(ROWLOCK)
SET Col1 = 1 ,col2=2
where col3=1;
BEGIN TRANSACTION
UPDATE transak
SET Col1 = 1 ,col2=2
where col3=1;
COMMIT;
As update creates lock on updated row, I think it will prevent other transaction to update same column/row value.
February 13, 2023 at 8:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
Rowlock: avoid escalation to page/tablelock
More detail: https://learn.microsoft.com/en-us/answers/questions/150070/sql-server-when-to-use-rowlock-updlock-etc
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply