June 10, 2014 at 8:47 am
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.
June 10, 2014 at 8:55 am
azhar.iqbal499 (6/10/2014)
when I run below query I got Error of Arithmetic overflow error converting numeric to data type numericdeclare @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/
June 10, 2014 at 8:55 am
That's because 16 is the full length. From those 16 positions you need to substract 4 for decimal positions. That gives you 12 positions on the left and 4 positions to the right.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply