Skip to content

Instantly share code, notes, and snippets.

@mavencode01
Forked from jdaigle/gist:2781344
Created March 9, 2016 19:52
Show Gist options
  • Save mavencode01/c9b3995e9266260d7f73 to your computer and use it in GitHub Desktop.
Save mavencode01/c9b3995e9266260d7f73 to your computer and use it in GitHub Desktop.
SQL Server Service Broker: Short Script to clear DISCONNECTED_INBOUND conversations
DECLARE @handle UNIQUEIDENTIFIER;
WHILE (SELECT COUNT(*) from sys.conversation_endpoints (nolock) where state_desc = 'DISCONNECTED_INBOUND') > 0
BEGIN
SELECT TOP 1 @handle = conversation_handle from sys.conversation_endpoints (nolock) where state_desc = 'DISCONNECTED_INBOUND';
END CONVERSATION @handle WITH CLEANUP
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment