ALTER PROCEDURE dbo.StoredProcedure8
@emp_code bigint,
@co_id bigint,
@p decimal(8,2) output
AS
SELECT @p = (select sum(tran_value) from emp_ded_ben_trans where emp_code=@emp_code and co_id=@co_id and period_flg=2 and tax_flg=0)
RETURN
ALTER PROCEDURE dbo.StoredProcedure8 @emp_code bigint, @co_id bigint, @p decimal(8,2) output AS SELECT @p =
Share
Stored procedures aren’t made to “return values” – that’s what you have stored functions for.
You can then call this stored function like this:
and get back a DECIMAL(8,2) from the calculation.
Stored procedures will return the number of rows affected by their operation – an INT.
If you need to return a value from a stored proc, you need to use the OUTPUT parameter type and use the technique that AdaTheDev shows – you need to grab the output value into a variable.