July 4, 2009 at 5:22 am
If my SP has the following parameters
a="hyderabad" string
b=10.145
c=a+b
I want my storedprocedure to return the value of c?
is it possible to do so.
July 4, 2009 at 5:31 am
what are the data types of b and c and what is the expected output?
July 6, 2009 at 8:31 am
There are 2 ways to return a single value from a stored procedure, as a resultset and as an output parameter and the recommended method would to use an output parameter. Here's are examples the first being returning the value a s a resultset and the second as an output parameter
Create Procedure variable_as_result_set
AS
SET NOCOUNT ON
declare @a varchar(100)
declare @b-2 float
declare @C varchar(max)
select @a ='hyderabad'
select @b-2= 10.145
select @C=@a + cast(@b as varchar(max))
Select @C AS C
Return
Alter Procedure variable_as_outputparameter
(
@C VARCHAR(MAX) OUTPUT
)
AS
SET NOCOUNT ON
declare @a varchar(100)
declare @b-2 float
select @a ='hyderabad'
select @b-2= 10.145
select @C=@a + cast(@b as varchar(max))
RETURN
GO
-- Example call of procedure using output paramter
DECLARE @output_param VARCHAR(MAX)
Exec variable_as_outputparameter @C = @output_param OUTPUT
SELECT @output_param
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply