Database Reference
In-Depth Information
where ProcessingTime <= @EarliestProcessingTime
order by ID
)
update DataPacket
set ProcessingTime = getutcdate()
output inserted.ID, inserted.Attributes into @Data(ID, Attributes)
By specifying UPDLOCK hint, we force SQL Server to use update (U), rather than shared (S) locks during select.
This prevents other sessions from reading the same rows simultaneously. At the same time, READPAST hint forces the
sessions to skip the rows with incompatible locks held, rather than being blocked.
Although both implementations accomplish the same goal, they use different approaches. The latter serializes
access to the same rows by using data (row level) locks. Application locks serialize access to the code and prevent
multiple sessions from running the statement simultaneously. This can be very useful in cases in which we want to
prevent some code from being executed in parallel.
 
Search WWH ::




Custom Search