Monday, September 8, 2008

Sql broker - Helper code snippet - Cleaning open conversation endpoints

That is just in development until you start ending all of your conversations etc, your endpoints might pile up :).

DECLARE @conversation_handle uniqueidentifier
 
DECLARE OpenMessages CURSOR FOR
SELECT conversation_handle 
FROM sys.conversation_endpoints where state = 'CO'
OPEN OpenMessages;
 
FETCH NEXT FROM OpenMessages INTO @conversation_handle
WHILE (@@FETCH_STATUS <> -1)
BEGIN
    PRINT @conversation_handle
    IF (@conversation_handle IS NOT NULL) END CONVERSATION @conversation_handle 
   FETCH NEXT FROM SampleCrsr INTO @conversation_handle
END
 
CLOSE OpenMessages;
 
DEALLOCATE OpenMessages;

1 comment:

Anonymous said...

Well said.