Arithmetic overflow error converting float to data type numeric

Hello guys,

I have a query that is resulting me an error:

Arithmetic overflow error converting float to data type numeric

``````SELECT
convert(numeric(14,2),round(convert(numeric(17,8),qtdpro)*round(convert(numeric(17,8),prunit)*convert(numeric(17,8),(1-(a.pdes/100)) ), dbo.fn_DigitosValor())  +convert(numeric(17,2),(a.FRETE+a.SEGURO+a.OUTDESP),2),2)) as BASCSLL
from aripco a,arpco b
where (a.numped = b.numped and a.seqped = b.seqped)
and qtdpro > 0
and prunit > 0
and b.flagoriginal = 0
``````

How could I get the row that is resulting me this error?

Thanks
Alex
LVL 1
Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sr. Software EngineerCommented:
You will want to look at the definition of how large/precise a float can be compared to a numeric.  Also, a float is by definition "approximate" while a numeric is "precise".
Microsoft docs say
Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly.
.  See https://docs.microsoft.com/en-us/sql/t-sql/data-types/float-and-real-transact-sql

You probably have a float that is larger (either positive or negative) than the maximum/minimum values for numeric.  Look up the definition of numeric and do a query where the float value is above/below the maximum/minimum.
0

Experts Exchange Solution brought to you by