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 
  and (B.FLAGFINALIZADO = 0)

Open in new window


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

Thanks
Alex
LVL 1
hidrauAsked:
Who is Participating?
 
larryhConnect With a Mentor 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
 
hidrauAuthor Commented:
Thanks a lot
0
 
hidrauAuthor Commented:
thanks a lot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.