Delete messages in service broker queue

前端 未结 5 512
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-24 07:31

I\'d like to clear my queue in SQL Server Management Studio, but I don\'t want to delete the whole queue just the content in the queue (the messages).

5条回答
  •  独厮守ぢ
    2020-12-24 08:18

    Something like this should work:

    while(1=1)
    begin
        waitfor (
            receive top(1)
            conversation_group_id
            from dbo.yourQueue
        ), timeout 1000;
    
        if (@@rowcount = 0)
            break;
    end
    

提交回复
热议问题