Listing 2: Managing Multiple Conversations’ Code
--@current_thread is a random number between 1 and max. thread number
SELECT TOP(@current_thread)
@dialog_handle = [conversation_handle]
FROM sys.conversation_endpoints with(nolock)
WHERE [state] = 'co'
AND far_service = 'TargetService'
ORDER BY lifetime DESC;
IF @@rowcount