存储过程返回.00十进制

时间:2010-08-04 13:39:18

标签: sql sql-server sql-server-2005 tsql

此存储过程不返回小数格式为00.00的工资

ALTER PROCEDURE taxable_varsalary

@emp_code bigint,
@co_id bigint      

AS
declare @t_varsalary decimal(8,2)

set @t_varsalary  = (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 @t_varsalary 

4 个答案:

答案 0 :(得分:5)

ALTER PROCEDURE taxable_varsalary

 @emp_code bigint,
 @co_id bigint,
 @t_varsalary decimal(8,2) OUTPUT

AS

   select @t_varsalary  = 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

存储过程的返回值必须是int。请改用输出参数或select

答案 1 :(得分:2)

存储过程返回仅返回integer,使用OUTPUT参数或在结尾处执行SELECT

答案 2 :(得分:1)

创建标量值函数

CREATE FUNCTION taxable_varsalary
    @emp_code bigint,
    @co_id bigint
RETURNS DECIMAL(8,2)
AS
declare @t_varsalary decimal(8,2)

set @t_varsalary  = (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 @t_varsalary 

答案 3 :(得分:0)

使用OUTPUT检查以下内容:

ALTER PROCEDURE taxable_varsalary

@emp_code bigint,
@co_id bigint      

AS
BEGIN
declare @t_varsalary MONEY

set @t_varsalary  = (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)

SELECT @t_varsalary OUTPUT

END