Home Forums SQL Server 2008 T-SQL (SS2K8) Arithmetic overflow error converting numeric to data type numeric RE: Arithmetic overflow error converting numeric to data type numeric

  • azhar.iqbal499 (6/10/2014)


    when I run below query I got Error of Arithmetic overflow error converting numeric to data type numeric

    declare @a numeric(16,4)

    set @a=99362600999900.0000

    the 99362600999900 value before numeric is 14 and variable that i declared is of 16 length. Then why this error is coming ? When I set Length 18 then error removed.

    You might want to visit BOL and look at the numeric datatype. http://msdn.microsoft.com/en-us/library/ms187746.aspx

    You are trying to shove 18 digits into a numeric that can only hold 16. The precision is the maximum number of digits, not just the integer portion.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/