Can I Select and Update at the same time?

Posted by Ed Manet on Stack Overflow See other posts from Stack Overflow or by Ed Manet
Published on 2010-02-19T13:52:55Z Indexed on 2012/04/11 5:28 UTC
Read the original article Hit count: 166

Filed under:

This is an over-simplified explanation of what I'm working on.
I have a table with status column. Multiple instances of the application will pull the contents of the first row with a status of NEW, update the status to WORKING and then go to work on the contents.
It's easy enough to do this with two database calls; first the SELECT then the UPDATE. But I want to do it all in one call so that another instance of the application doesn't pull the same row. Sort of like a SELECT_AND_UPDATE thing.

Is a stored procedure the best way to go?

© Stack Overflow or respective owner

Related posts about sql-server