Q:

Getting an error when casting float to decimal

Moving data from flost to decimal(5,2).  largest value I could find int he existing data is 94.23 but when I try to cast to decimal it throws error.
Arithmetic overflow error converting float to data type numeric.

I tried copying straight over without casting, got that error.  So then I tried casting first:
     CAST(Purity as decimal(5,2))

Same error.
I noticed there are also nulls in there so I tried:
ISNULL(CAST(Purity as decimal(5,2)),0)

Same error.

A:

Did you look for the largest value in the database?
select max(Purity)
from t;

And, in the event that Purity is really a string, you might have other things going on.  So, you can try:
select max(convert(purity, 18, 6))  -- or something like this
from t;

