views:

64

answers:

3

this stored procedure does not return salary with decimal format 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  A: 
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

The return value for a stored procedure has to be an int. Use an output parameter instead or select it

Martin Smith
(or a data set with one row and one column)
Philip Kelley
@Martin: I do agree, I didn't noticed that shmandor is returning some value. +1 for good catch
Shantanu Gupta
@shmandor - I'm not sure what that comment means!
Martin Smith
@smith -kelley said there no data put i am sure there are data returned from query
shmandor
What is your question? Have you tried using the query in my answer?
Martin Smith
+2  A: 

A stored procedure return only returns an integer, either use an OUTPUT parameter or do a SELECT at the end

SQLMenace
A: 

Create a Scalar-Valued Function:

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 
Rabid