Arith overflow error converting int/numeric to data type numeric

  • Hi,

    I did not get what is wrong with the below piece of code?

    declare @VERS numeric(2,2)

    set @VERS = 1

    --or

    --set @vers = 1.00

    select @VERS

    I get error

    when set @vers = 1

    Arithmetic overflow error converting int to data type numeric.

    when set @vers = 1.00

    Arithmetic overflow error converting numeric to data type numeric.

    This works fine when when set @vers = 0. Any ideas?

    Thanks

    KB

    Thanks,
    Santhosh


    Human Knowledge Belongs To The World !!

  • KBSK (11/25/2010)


    Hi,

    I did not get what is wrong with the below piece of code?

    declare @VERS numeric(2,2)

    set @VERS = 1

    --or

    --set @vers = 1.00

    select @VERS

    I get error

    when set @vers = 1

    Arithmetic overflow error converting int to data type numeric.

    when set @vers = 1.00

    Arithmetic overflow error converting numeric to data type numeric.

    This works fine when when set @vers = 0. Any ideas?

    Thanks

    KB

    Numeric(2,2) doesnt mean xx.xx it means .xx so it can hold any value between 0.99 and -0.99 but nothing else.

    First value is the number of digits and the second one is how many of those are in the decimalpart.

    So Numeric(3,2) would work better if you want to set it to 1.00.

    /T

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

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