2010-08-04 71 views
2

這個存儲過程不與十進制格式00.00存儲過程返回0.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 [email protected]_code and [email protected]_id and period_flg=2 and tax_flg=0) 

RETURN @t_varsalary 
+0

回報只適用於int值秒。 – 2017-08-22 10:37:52

回答

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 [email protected]_code and [email protected]_id and period_flg=2 and tax_flg=0 

爲存儲過程的返回值必須是一個int返回薪水。使用輸出參數,而不是或select

+0

(或一行一列的數據集) – 2010-08-04 13:44:54

+0

我同意,我沒有注意到shmandor正在返回一些價值。 +1爲好趕上 – 2010-08-04 13:45:12

+0

@shmandor - 我不確定那個評論意味着什麼! – 2010-08-04 14:11:20

2

存儲過程返回只返回一個integer,要麼使用OUTPUT參數或在年底做一個SELECT

0

創建標量值函數

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 [email protected]_code and [email protected]_id and period_flg=2 and tax_flg=0) 

RETURN @t_varsalary 
下面
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 [email protected]_code and [email protected]_id and period_flg=2 and tax_flg=0) 

SELECT @t_varsalary OUTPUT 

END