用户进程中发生浮点异常错误。已取消当前事务.
昨天在存储过程中遇到这么一个错误,暂时没有应对办法,
今天再去执行这个存储过程的时候,这个问题却没有了,
在网上搜索了一下,也没什么好的处理办法,来这里看看。
问题是出现在这句SQL上:
update t_a set sl=b.sl 
from t_a a join 
(select sum(sl) as sl,ddid from t_b where [id] in (select [id] from t_c where cdate>='2010-7-1' and cdate<'2010-7-15') group by ddid) b 
on a.ddid=b.ddid当时怀疑是数据类型转换导致的问题
因为 t_a.sl:numeric(18,2)
     t_b.sl: float --数据中带有很多小数位
后来又发现
select * from t_b where [id] in (select [id] from t_c where cdate>='2010-7-1' and cdate<'2010-7-15') and sl>100 
只要执行这句查询也会出现:用户进程中发生浮点异常错误。已取消当前事务.
但是执行
select * from t_b where [id] in (select [id] from t_c where cdate>='2010-7-1' and cdate<'2010-7-15')
却正常返回结果集,当时马上怀疑是不是数据表损坏了。
今天再来处理的时候结果存储过程和查询都能正常执行,
服务器用的是SQLServer2000,确认打上SP4补丁的
Microsoft SQL Server  2000 - 8.00.2040 (Intel X86)   May 13 2005 18:33:17   Copyright (c) 1988-2003 Microsoft Corporation  Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2) 恭听大家见解

解决方案 »

  1.   

    建议你改一下数据类型:同时为float或numeric类型,格式化小数点,比如两个数的小数位数一样多,因为你是sum数据,而且小数点多位存在四舍五入,到底数据错在哪比较难检查,所以建议改为数据类型一样,小数位数也一样多,这样试一下是否有问题?
      

  2.   

    看起来是SQL2000的BUG.SP4修正的不彻底?
      

  3.   

    浮点运算 这个感觉不像sql server控制的
      

  4.   

    我觉得不是数据类型转换的问题了,你没看到我说的吗?select * from t_b where [id] in (select [id] from t_c where cdate>='2010-7-1' and cdate<'2010-7-15') and sl>100  
    只要执行这句查询也会出现:用户进程中发生浮点异常错误。已取消当前事务.