As a general rule, SQL is build to handle group of records (matching criteria) simultaneously. Your description looks like you are thinking linear processing, which will not work that well with SQL and it will definately not allow you to use your server 100%.
Anyway, you'll need to provide more info on what you are building, perhaps other have done something similar and can share practises or we can get a better idea of your need.
Assuming a lot, if this is not a time critical application, you could search for the 1st unhandled '2' and get all messages followed by that in a 5 min window. Unfortunately you'd have to run this every x mins and would read messages already in the db - it won't wait for new messages to act on.
adam_k
Practically a Posting Shark
804 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149