将浮点数转换为小数时出错
Getting an error when casting float to decimal
将数据从 flost 移动到 decimal(5,2)。我可以在现有数据中找到的最大值是 94.23,但是当我尝试转换为十进制时,它会抛出错误。
Arithmetic overflow error converting float to data type numeric.
我尝试直接复制而不进行转换,但出现了错误。所以我先尝试投射:
CAST(Purity as decimal(5,2))
同样的错误。
我注意到那里也有空值,所以我尝试了:
ISNULL(CAST(Purity as decimal(5,2)),0)
同样的错误。
您是否在数据库中查找最大值?
select max(Purity)
from t;
而且,如果 Purity
确实是一个字符串,您可能还有其他事情要发生。所以,你可以试试:
select max(convert(purity, 18, 6)) -- or something like this
from t;
将数据从 flost 移动到 decimal(5,2)。我可以在现有数据中找到的最大值是 94.23,但是当我尝试转换为十进制时,它会抛出错误。
Arithmetic overflow error converting float to data type numeric.
我尝试直接复制而不进行转换,但出现了错误。所以我先尝试投射:
CAST(Purity as decimal(5,2))
同样的错误。
我注意到那里也有空值,所以我尝试了:
ISNULL(CAST(Purity as decimal(5,2)),0)
同样的错误。
您是否在数据库中查找最大值?
select max(Purity)
from t;
而且,如果 Purity
确实是一个字符串,您可能还有其他事情要发生。所以,你可以试试:
select max(convert(purity, 18, 6)) -- or something like this
from t;