Thursday 16 October 2008

How to cleanup SQL Server Service Broker

If you need to cleanup or reset Service Broker, you may find useful this short script that shuts down all open conversations and cleans up the Service Broker queue.

 

declare @u uniqueidentifier

select top 1 @u=conversation_handle from sys.conversation_endpoints

while @u is not null begin

  END CONVERSATION @u WITH CLEANUP

  set @u = null

  select top 1 @u=conversation_handle from sys.conversation_endpoints

end

 

Hope that helps.

No comments: