Saturday, November 17, 2012 6:19 PM
Saturday, November 17, 2012 11:00 PM
One method is to initialize @RecvReplyDlgHandle to NULL and check for NULL after the RECEIVE:
DECLARE @RecvReplyMsg NVARCHAR(100) = NULL @RecvReplyDlgHandle UNIQUEIDENTIFIER = NULL; BEGIN TRANSACTION; RECEIVE TOP(1) @RecvReplyDlgHandle = conversation_handle ,@RecvReplyMsg = message_body FROM TargetQueue; IF @RecvReplyDlgHandle IS NOT NULL BEGIN END CONVERSATION @RecvReplyDlgHandle; END; SELECT @RecvReplyMsg AS ReceivedReplyMsg; COMMIT TRANSACTION;
The application can check ReceivedReplyMsg for NULL to indicate no message was received.
Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
Sunday, November 18, 2012 9:02 AMModerator
Please wrap your END CONVERSATION and SELECT ... in a:
if(@@rowcount <> 0)
end conversation ...
TechNet Community Support