Number and Decimal conversions

  • Hi all,

    I have this stored procedure but everytime I run it - the output is a whole number but I want it to be a decimal number. Can anyone assist? The procedure is below. Thanks.

    create procedure Test_Decimal

    @Protocol_Number numeric,

    @Stage1_VO2 decimal(2) Output

    AS

    select @Stage1_VO2 =

    case

    when @Protocol_Number=1 then 9.60

    when @Protocol_Number=2 then 11.90

    when @Protocol_Number=3 then 14.60

    when @Protocol_Number=4 then 17.80

    when @Protocol_Number=5 then 20.60

    when @Protocol_Number=6 then 23.30

    when @Protocol_Number=7 then 26.00

    when @Protocol_Number=8 then 28.70

    else 0

    end

  • Decimal(2) means 2 digits, nothing to the right of the decimal. I think what you want is:

    create procedure Test_Decimal

    @Protocol_Number numeric,

    @Stage1_VO2 decimal(4,2) Output

    AS

    select @Stage1_VO2 =

    case

    when @Protocol_Number=1 then 9.60

    when @Protocol_Number=2 then 11.90

    when @Protocol_Number=3 then 14.60

    when @Protocol_Number=4 then 17.80

    when @Protocol_Number=5 then 20.60

    when @Protocol_Number=6 then 23.30

    when @Protocol_Number=7 then 26.00

    when @Protocol_Number=8 then 28.70

    else 0

    end


    And then again, I might be wrong ...
    David Webb

  • this works! thanks very much.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply