Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • When I use this the update statement waits until the lock is released and then perform an update. I don't want this behavior. As soon a record is blocked, the user must see a message. Doing it this way, I can't notify the user because the update statement waits until the lock is released. I want the update statement to stop and give somehow an error/exception/warning so I can notify the user. Commented Sep 22, 2010 at 8:33
  • @Martijn - Your second update statement needs to be executed with the NOWAIT hint, which will cause it to return as soon as a lock is encountered rather than wait for the timeout. Commented Sep 22, 2010 at 9:46
  • Shouldn't the statement read SELECT id From mytable WITH (ROWLOCK, UPDLOCK) WHERE id = 1? Commented Mar 5, 2012 at 20:34