--Grab the next message id
declare @MessageId uniqueidentifier
set @MessageId = (select top(1) ActionMessageId from UnacknowledgedDemands);
--Acknowledge the message
update ActionMessages
set AcknowledgedTime = getdate()
where ActionMessageId = @MessageId
--Select the entire message
...
...
在上述代码中,是否可能同时运行另一个存储过程并获取相同的id,然后尝试同时确认它?我是否应该实现某种锁定以防止另一个存储过程确认另一个存储过程正在查询的消息?
哇,这是否有任何意义?用言语表达有点困难...