• 消息 8134,级别 16,状态 1,第 1 行 遇到以零作除数错误


      这两天遇到一个非常奇怪的问题,给人的感觉有点匪夷所思,如下所示,在更新一个表的统计信息时,会遇到“遇到以零作除数错误”,本来这个错误是属于数学错误,但是居然出现在更新统计信息的SQL语句里面

    UPDATE STATISTICS [dbo].[FIInspectFabric] SAMPLE 20 PERCENT;

    消息 8134,级别 16,状态 1,第 1 行

    遇到以零作除数错误。

     

    UPDATE STATISTICS [dbo].[FIInspectFabric] WITH FULLSCAN;

    消息 8134,级别 16,状态 1,第 1 行

    遇到以零作除数错误。

    clipboard

    如果我更新统计信息的SQL语句不带参数,则会执行成功。如下所示

    UPDATE STATISTICS [dbo].[FIInspectFabric];

     

    DBCC CHECKTABLE('FIInspectFabric')也没有发现任何问题,Google、Bing搜索了很久也没有查到相关资料。

    image

    问题出在哪里?一直没有答案。直到我检查这个表的索引时,发现在表FIInspectFabric的字段A、B上建立了主键索引、然后不知道那个程序员又在字段A上建立了两个索引(严重鄙视之),于是删除了这两个索引后,重新执行上面语句OK,问题消失了,于是我建立了测试表,想重现这个错误,很奇怪,怎么也重现不了这个错误。

     

    ====***************************************************2015-07-21日补充************************************************====

    今天又出现了这个错误,重建索引后,问题依然存在,在检查这个表的统计信息时,发现除了索引对应的统计信息外,还有大量额外的统计信息,于是我将这些统计信息全部删除(系统会根据需要自动建立)。然后去跟新统计信息,问题解决。

    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000006_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000007_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000008_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000009_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000000A_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000000B_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000000C_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000000D_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000000E_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000000F_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000010_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000011_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000012_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000013_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000014_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000015_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000016_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000017_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000018_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000019_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000001B_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000001D_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000001E_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000001F_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000020_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000021_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000022_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000023_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000024_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000025_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000026_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000027_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000028_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000029_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000002A_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000002B_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000002C_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000002D_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000002E_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000002F_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000030_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000031_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000032_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000033_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000034_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000035_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000036_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000003C_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000003F_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000040_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000041_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000042_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000043_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000044_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000045_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000046_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000047_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000048_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_00000049_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000004C_712A3EA0
    DROP STATISTICS FIINSPECTFABRIC._WA_Sys_0000004E_712A3EA0

    ====***************************************************2017-06-09日补充************************************************====

    今天同事反馈在SELECT这个表的时候也遇到了这个错误,我立马想到了可能是有计算列的问题,检查了一下表结构,发现有一个字段确实是用其它列计算,终于解开了这个案例的谜底! 只是在这种机缘巧合的情况下,总有点怪怪的感觉,试想,如果当时检查一下表结构,也许就能解开真相了!

     

    [HundredYard_Points] AS (case when [Quantity]=(0) then (0) else floor(((isnull([Total_Def_Point_SendedYorn],[Total_Def_Point])*(3600))/(isnull([Width],(1))*(isnull([Quantity],(1))-isnull([Allow_Quantity],(0)))))*(100))/(100) end)

  • 相关阅读:
    variables _ golang
    values _ golang
    hello world _ golang
    golang
    英语
    ubuntu下安装node、node代码调试
    xampp日常需求
    垂直居中方法总结
    angularJS之ui-router插件(1)
    Sass学习
  • 原文地址:https://www.cnblogs.com/kerrycode/p/4212777.html
Copyright © 2020-2023  润新知