是否有一种快速删除Service Broker队列的方法

Mar*_*own 3 sql-server service-broker sql-server-2008-r2

我一直在运行一个涉及Service Broker队列的负载测试.出了点问题,队列最终收到了130万条消息.我只想清除这些,没有备份,也不需要记录.麻烦的是,当我尝试删除队列时,它花了半个小时,然后日志文件填满,整个事情回滚.是否有一种快速而肮脏的方式将所有内容都清除出队列?

Gau*_*ssZ 6

您可以使用以下语句一次清除所有会话:

declare @conversationHandle uniqueidentifier 
select top 1 @conversationHandle = conversation_handle from sys.conversation_endpoints    
while @@rowcount = 1

begin    
     end conversation @conversationHandle with cleanup    
     select top 1 @conversationHandle = conversation_handle from sys.conversation_endpoints    
end
Run Code Online (Sandbox Code Playgroud)