Solved

# CASE STATEMENT RETURNING NULLS

Posted on 2007-12-05

I am writing this function and when i call it with a select statement I am getting nulls. Any ideas?

ALTER FUNCTION [dbo].[fn_deductible]

(

-- Add the parameters for the function here

@DEDUCTIBLEAMT VARCHAR(7)

)

RETURNS varchar (1)

AS

BEGIN

-- Declare the return variable here

DECLARE @DEDUCTIBLE varchar(1)

DECLARE @DEDUCTIBLETEMP varchar(7)

-- Add the T-SQL statements to compute the return value here

SET @DEDUCTIBLETEMP = CAST(@DEDUCTIBLEAMT AS NUMERIC (7,0))

set @DEDUCTIBLE = case @DEDUCTIBLETEMP

when '> 100 and <= 250' then '4'

when '> 500 and <= 750' then '6'

when '> 750 and <= 1000' then '7'

when '> 1000 and <= 2500' then '8'

when '> 2500 and <= 5000' then '9'

when '> 5000 and <= 10000' then 'A'

when '> 10000 and <= 25000' then 'B'

when '> 25000 and <= 50000' then 'C'

when '> 50000 and <= 75000' then 'D'

when '> 75000 and <= 100000' then 'E'

when '> 100000 and <= 200000' then 'F'

when '> 200000 and <= 250000' then 'G'

when '> 250000 and <= 300000' then 'H'

when '> 300000 and <= 400000' then 'I'

when '> 400000 and <= 500000' then 'J'

when '> 500000' then 'k'

end

RETURN @DEDUCTIBLE

END