SEND (Transact-SQL)
Sends a message by using an existing conversation.
- ON CONVERSATION conversation_handle
-
Specifies the conversation that the message belongs to. The conversation_handle must contain a valid conversation identifier.
- MESSAGE TYPE message_type_name
-
Specifies the message type of the sent message. This message type must be included in the service contract used by this conversation. The contract must allow the message type to be sent from this side of the conversation. For example, the target of the conversation can only send messages specified in the contract as SENT BY TARGET or SENT BY ANY. If this clause is omitted, the message is of the message type DEFAULT.
- message_body_expression
-
Provides an expression representing the message body. The message_body_expression is optional. However, if the message_body_expression is present the expression must be of a type that can be converted to varbinary(max). The expression cannot be NULL. If this clause is omitted, the message body is empty.
Important: |
|---|
| If the SEND statement is not the first statement in a batch or stored procedure, the preceding statement must be terminated with a semicolon (;), the Transact-SQL statement terminator. |
The SEND statement locks the conversation group that the specified conversation handle belongs to.
SEND is not valid in a user-defined function.
A. Sending a message
This example starts a dialog and sends an XML message on the dialog. To send the message, the example converts the xml object to varbinary(MAX).
DECLARE @dialog_handle UNIQUEIDENTIFIER,
@ExpenseReport XML ;
SET @ExpenseReport = < construct message as appropriate for the application > ;
BEGIN DIALOG @dialog_handle
FROM SERVICE [//Adventure-Works.com/Expenses/ExpenseClient]
TO SERVICE '//Adventure-Works.com/Expenses'
ON CONTRACT [//Adventure-Works.com/Expenses/ExpenseProcessing] ;
SEND ON CONVERSATION @dialog_handle
MESSAGE TYPE [//Adventure-Works.com/Expenses/SubmitExpense]
(@ExpenseReport) ;
Reference
BEGIN DIALOG CONVERSATION (Transact-SQL)BEGIN CONVERSATION TIMER (Transact-SQL)
END CONVERSATION (Transact-SQL)

Important: