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....
Welcome to the forums. Make sure you follow the forum policies and do not duplicate the posts with same problem, see http://sql-server-performance.com/Community/forums/t/31029.aspx fyi