I am trying to use a table as a heap queue. However I am having a little trouble figuring out how to take the text that is generated in the dequeue function and perform a execute on it.
Here is the table storing the queue and the dequeue method.
CREATE TABLE [dbo].[Merge_Queued_Work](Sql_Text varchar(2000) NOT NULL)
GO
create procedure usp_dequeueWork
as
set nocount on;
delete top(1) from [Merge_Queued_Work] with (rowlock, readpast)
output deleted.[Sql_Text];
go
How do I get the varchar from deleted.[Sql_Text] to a execute statement?
Capture the output in a table variable and fill a varchar variable from the table variable.