How to apply lock on table.?
or
How to Lock perticular row from table?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 1, 2014, 8:47 AM EDT
SELECT *
FROM authors
WITH (HOLDLOCK, ROWLOCK)
WHERE au_id = 142
/* Do all your stuff here while the record is locked */
COMMIT TRAN
Note: The HOLDLOCK hint will instruct SQL Server to hold the lock until you commit the transaction. The ROWLOCK hint will lock only this record and not issue a page or table lock.
Abhay ShankerRank #375 · 6.7K reputationPosted Jul 1, 2014, 9:21 PM EDT
UPDATE
Employees WITH (HOLDLOCK,ROWLOCK)
SET Salary=454545
WHERE Id=3
COMMIT TRAN
Check below urls for more detail
http://technet.microsoft.com/en-us/library/ms378471(v=sql.110).aspx
http://www.sqlteam.com/article/row-locking