You can use the advice in this article and the server-side process queue. Then your code might look like
create table TQueue (TableName nvarchar(128), PrimaryKey int, Action nvarchar(128)) create procedure sp_TQueue_Pop as begin declare @TableName nvarchar(128), @PrimaryKey int, @Action nvarchar(128) declare @temp_pop table (TableName nvarchar(128), PrimaryKey int, Action nvarchar(128)) begin transaction select @TableName = null, @PrimaryKey = null, @Action = null delete top (1) from TQueue with (rowlock, readpast) output deleted.* into @temp_pop select @TableName = TableName, @PrimaryKey = PrimaryKey, @Action = Action from @temp_pop
to remove from the queue, you have just completed the procedure.
Hope this helps.
source share