Monday, March 26, 2012

Is It possible to have a stored procedure that returns 2 values?

Is It possible to have a stored procedure that returns 2 values?
and call it from a C# webforms application.
Thanks.Do you mean two datatables in one dataset or what?|||output parameters?|||Hi, I mean 2 output values.
My Store Proc is a select query on 1 table in 1 database that I want to return 2 values from.
Thanks.|||If it is a single value, you may try ouput parameter.|||Let me repeat it again...
Hi, I mean (2 output values).
My Store Proc is a select query on 1 table in 1 database that I want to return 2 values from.
Does anyone have a exmple on how to do this..
I know how to do 1 output value but 2 I don't know how.
Thanks.|||the proc would look something like this and in your vb or c# code you would specify the parameters direction as Output or OutputInput then you can get the value out of the parameter value property I believe

CREATE PROCEDURE [OutputParamProc]
@.ItemID int,
@.OutputValue1 int output,
@.OutputValue2 int output
AS
SET NOCOUNT ON

Declare @.Rv int

SELECT @.OutputValue1 = Somecolumn1,
@.OutputValue2 = Somecolumn2

FROM SomeTable
WHERE SomeColumn = @.ItemID

SET @.Rv = @.@.Error

RETURN @.Rv

|||Thanks man that's what I needed.

No comments:

Post a Comment