SQL Server Performance

Coding fo Concurrency

Discussion in 'General Developer Questions' started by rw610, Oct 16, 2009.

  1. rw610 New Member

    This question must have been answered a hundred times but I cannot seem to find the answer.
    I have an application that needs to read work off a queue (the queue is a database table). There are many instances (hundreds) of the application running and every instance will be looking for the first item in the queue which has not yet been processed - the status column on the table = 0. I am not worried about the order in which the queue items are processed, I just want to pull back the first item and work with it but I must not pull back an item that is alreday being processed by another instance.
    I know that I can read an item from the queue and then 'lock' it by updating its status but how do I prevent another instance from reading this item and trying to work with it at the same time?
    My thanks for your help....
  2. satya Moderator

Share This Page