Convert to numeric overflow issue

  • I have a column in a table that is decimal(22,6).

    When I try to convert it to decimal(22,8), I get the error

    Arithmetic overflow error converting numeric to data type numeric.

    I cant see why I get an overflow trying to put a smaller number into a bigger one.

    Can anyone explain what im missing?

    Note it only happens on certain rows, and I have not identified them yet, but will post when I do.

  • The original definition would hold

    1234567890123456.123456

    The new definition won't. So if you have a number with greater than 14 positions left of the decimal, you'll get a message. That's the only thing I can think of that would give you the error.


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

  • You're not putting a smaller number into a bigger one. You should try decimal(24,8).

    decimal(22,6) ranges are

    -9,999,999,999,999,999.999999 to 9,999,999,999,999,999.999999

    decimal(22.8) are

    -99,999,999,999,999.99999999 to 99,999,999,999,999.99999999

    so they are significantly smaller (100 times).

    That's why you need to increase precision if you increase the scale.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • thanks guys. perfect explination. I was incorrectly viewing how decimal/numeric are formatted. Issue resolved.

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

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