I have a stored proc that has this UPDATE query:
UPDATE TOP(1) Batch_tbl
SET locked = 1
OUTPUT inserted.batchId INTO #batchId
FROM Batch_tbl
WHERE locked =
No. When SQL Server wants to update a row, an UPDATE
lock is acquired. This is compatible with other locks, like a shared lock (to read), but it's NOT compatible with another update lock.
So if two concurrent users attempt to update the same row, one of them will "win" and get the UPDATE
Lock, while the other user / transaction will have to wait until the first update is done.