Share via


SqlPipe.Send Method

Definition

Sends results directly to the client or current output consumer.

Overloads

Send(SqlDataRecord)

Sends a single-row result set directly to the client or current output consumer.

Send(SqlDataReader)

Sends a multirow result set directly to the client or current output consumer.

Send(String)

Sends a string message directly to the client or current output consumer.

Remarks

The Send method sends data straight to the client or caller. It is usually the client that consumes the output from the Pipe method, but in the case of nested CLR stored procedures the output consumer can also be a stored procedure. For example, Procedure1 calls ExecuteReader with the command text "EXEC Procedure2". Procedure2 is also a managed stored procedure. If Procedure2 now calls Send, the row is sent to Procedure1's reader, not to the client.

Send(SqlDataRecord)

Sends a single-row result set directly to the client or current output consumer.

public:
 void Send(Microsoft::SqlServer::Server::SqlDataRecord ^ record);
public void Send (Microsoft.SqlServer.Server.SqlDataRecord record);
member this.Send : Microsoft.SqlServer.Server.SqlDataRecord -> unit
Public Sub Send (record As SqlDataRecord)

Parameters

record
SqlDataRecord

The single-row result set sent to the client: a SqlDataRecord object.

Exceptions

The record is null.

Applies to

Send(SqlDataReader)

Sends a multirow result set directly to the client or current output consumer.

public:
 void Send(System::Data::SqlClient::SqlDataReader ^ reader);
public void Send (System.Data.SqlClient.SqlDataReader reader);
member this.Send : System.Data.SqlClient.SqlDataReader -> unit
Public Sub Send (reader As SqlDataReader)

Parameters

reader
SqlDataReader

The multirow result set to be sent to the client: a SqlDataReader object.

Exceptions

The reader is null.

Remarks

If the SqlDataReader object passed in as a parameter has hidden columns, those columns are not propagated to the result set sent to the client.

Applies to

Send(String)

Sends a string message directly to the client or current output consumer.

public:
 void Send(System::String ^ message);
public void Send (string message);
member this.Send : string -> unit
Public Sub Send (message As String)

Parameters

message
String

The message string to be sent to the client.

Exceptions

The message is greater than 4,000 characters.

The message is null.

Examples

The following example uses the Send method to send a message string directly to the client.

[Microsoft.SqlServer.Server.SqlProcedure]
public static void StoredProcSendMessage()
{
    // Send a message string back to the client.
    SqlContext.Pipe.Send("Hello World!");
}
<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub StoredProcSendMessage()

    ' Send a message string back to the client.
    SqlContext.Pipe.Send("Hello world!")

End Sub

Remarks

The message string is sent as an informational message to the client. Client applications can listen to messages through different mechanisms, depending on the data access application programming interface (API) that they use. For example, if the client is using ADO.NET, the messages transmit through the InfoMessage event.

Applies to