I have a stored procedure with a select and an update. I would like to prevent multiple users, from executing it, at the same time, so I don’t update, based on an incorrect select.
How do I lock it?
I’ve read various solutions (Transaction isolation, xlock), but I haven’t been able to figure what I really want, and how to do it.
I have a stored procedure with a select and an update. I would like
Share
The easiest way is to forget about data locks but look at sp_getapplock to control access through the code
Saying that, with thing like the OUTPUT clause and judicious use of ROWLOCK, UPDLOCK there is a good chance the UPDATE and SELECT can be one statement