Pravin
Pravin

Reputation: 543

Call SQLCLR procedure from another stored procedure and get 2 return values?

I am using a stored procedure that calls another SQLCLR stored procedure. The SQLCLR procedure returns 2 values.

How to get 2 return values from SQLCLR procedure to the T-SQL stored procedure?

I know normally from C# getting the return value using output parameter. But confusing how to get and hold return value in normal stored procedure.

Upvotes: 3

Views: 723

Answers (2)

Pravin
Pravin

Reputation: 543

SQLCLR Procedure:

public static void SendMailSP(out string Status, out string Message)
{
    Status = "hi:";
    Message = "Hello";
}

DB Procedure

CREATE PROCEDURE [dbo].udpTestOutParameter
{
DECLARE @Status varchar(100);
DECLARE @Message varchar(100);
EXECUTE dbo.SendMailSP @Status = @Status OUTPUT,@Message = @Message OUTPUT;
PRINT @Status
PRINT @Message
RETURN
}

I am getting the proper result. Thanks for post.

Upvotes: 3

Brandon Moore
Brandon Moore

Reputation: 8780

There may be a more 'correct' answer than this, but one easy way is to just put the two values into one and separate them with some character such as a comma, tab, pipe, etc. So that way you are just returning one value and you can split it on the other end back into 2 values based on the delimeter.

Upvotes: 1

Related Questions