I have a simple query that I've turned into a stored proc:
create procedure GetAmount as
declare @amnt decimal(25,2)
select @amnt=66666.67
set @amnt = @amnt/3.00
print @amnt
return @amnt
If I print @amnt, it returns 22222.22
But if I use EXEC and assign it to a variable:
declare @x numeric(25,2)
exec @x=SP_GetAmount()
print @x
it returns 22222.00
Anyone know why?
Thanks
return
returns an integer. Use an output parameter.
create procedure GetAmount
@amnt decimal(25,2) OUTPUT
as
select @amnt=66666.67
set @amnt = @amnt/3.00
GO
And to call it:
declare @x numeric(25,2)
exec SP_GetAmount() @amnt = @x OUTPUT
print @x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With