转换数据发生
消息 8115,级别 16,状态 6,第 1 行
将 nvarchar 转换为数据类型 numeric 时出现算术溢出错误。
nvarchar 是带很长小数,直接转换成decimal 失败
解决方案:
先转换成float 再转换成decimal 或者int(去掉小数位)
CAST(CAST(TRANS_CHARGE AS FLOAT) AS INT)
Why float?
- no idea of precision or scale across all rows: float is the lesser evil perhaps
- empty string will cast to zero for float, fails on decimal
- float accepts stuff like 5E-02, fails on decimal
参考: