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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Jul 2, 2014, 1:21 AM
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
Ramesh MaruthiPosted Jul 1, 2014, 12:47 PM
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.