My (simplified) table consist of an
Id int identity(1,1),
File varchar(20),
FileProcessed bit
The logic is this: my application takes first (the order isn't important) record, which has FileProcessed bit set to false. Then it processes the file and sets the FileProcessed bit to true.
Now, it can happen, that the first thread takes a record with Id 1 and whilst processing it, another thread takes the same record with Id 1 (because it isn't market as processed).
What is the best way, to support miltithreading in this example?
EDIT: I use SQL Sever 2005 EDIT2: Processing of the file can take a long time, so I don't want to lock the whole table in the meanwhile