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
Stored procedures aren't made to "return values" - that's what you have stored functions for.
CREATE FUNCTION dbo.CalculateSomething
(@emp_code bigint, @co_id bigint)
RETURNS DECIMAL(8, 2)
AS BEGIN
RETURN
(SELECT SUM(tran_value)
FROM dbo.emp_ded_ben_trans
WHERE
emp_code = @emp_code AND co_id = @co_id
AND period_flg = 2 AND tax_flg = 0)
END
You can then call this stored function like this:
SELECT dbo.CalculateSomething(value_for_emp_code, value_for_co_id)
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.