I had such a situation.
Add a column InProcessto the table, default = 0. In the consumer process:
UPDATE tbl SET Inprocess = @myMachineID WHERE rowID =
(SELECT MIN(rowID) WHERE InProcess = 0)
Now this machine owns the string, and you can request its data without any fear. Typically, the following line will look something like this:
SELECT * FROM tbl WHERE rowID =
(SELECT MAX(rowID) FROM tbl WHERE ProcessID = @myMachineID)
You also need to add the string flag Doneto the string so that you can determine if the string was declared, but the processing was incomplete.
Edit
UPDATEgets an exclusive lock (see MSDN ). I am not sure if SELECTthe subquery is allowed to share with UPDATE; if so, you will have to put them in the transaction.
@Will A , , :
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
... .
@Martin Smith , OUTPUT ( SQL 2005).
, - . , SO, ?
: 2004 , -, URL- , URL-to-crawl . , .