一台SQL Server 2008 R2版本(具体版本如下所示)的数据库,最近几天更新统计信息的作业出错,错误如下所示:

Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)

Jun 28 2012 08:36:30

Copyright (c) Microsoft Corporation

Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

第一次碰到这么奇葩的问题。查看错误日志,就会发现更新统计信息时出现异常,生成了dump文件。

对表做DBCC CHECKTABLE发现正常,未有一致性错误。

DBCC CHECKTABLE('TBusRetail')

后面查了一下资料,在官方文档看到有个Bug会导致这个问题,官方文档为:FIX: An access violation may occur when you update the statistics of a table after you enable and then disable conflict detection on a table in in SQL Server 2008 or in SQL Server 2008 R2。刚好我们这个环境的版本也在其中。具体参考下面:

Cause

This issue occurs because the database engine is trying to load dangling statistics. When P2P conflict detection is enabled, an MDColumnIdP2pCdId system column is added to the base index rowset of the table. Replication-related queries may create statistics on the system column automatically. When P2P conflict detection is disabled, the system column is removed from the table. However, the corresponding statistics remain. Therefore, updating statistics causes the access violation exception to occur because the statistics cannot be added to the table.

SQL Server 2008 Service Pack 2

The fix for this issue was first released in Cumulative Update 3 for SQL Server 2008 Service Pack 2. For more information about this cumulative update package, click the following article number to view the article in the Microsoft Knowledge Base:

2498535 Cumulative update package 3 for SQL Server 2008 Service Pack 2

Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release. Microsoft recommends that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

2402659 The SQL Server 2008 builds that were released after SQL Server 2008 Service Pack 2 was released

Microsoft SQL Server 2008 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2008 Service Pack 2 hotfix to an installation of SQL Server 2008 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack.

The fix for this issue was first released in Cumulative Update package 6 for SQL Server 2008 R2. For more information about how to obtain this cumulative update package, click the following article number to view the article in the Microsoft Knowledge Base:

2489376 Cumulative Update package 6 for SQL Server 2008 R2

Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

981356 The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 was released

但是等我打上补丁后,测试发现问题依然存在,也只有这个表存在这个问题。后面仔细检查,发现这个表有不少计算列(Computed Column),刚好以前也遇到过由于计算列导致统计信息更新出现错误的情况,一检查,发现这表有大量的统计信息,遂生成删除统计信息的脚本后执行删除(排除了相关索引的统计信息)。然后再更新统计信息,OK,问题解决了。看来又是神奇的计算列(Computed Column)导致的统计信息更新异常!

SELECT  'DROP STATISTICS dbo.TBusRetail.' + QUOTENAME(name) + ';'

FROM    sys.stats

WHERE   object_id = OBJECT_ID('dbo.TBusRetail')

DROP STATISTICS dbo.TBusRetail.[PK_TBUSRETAIL];  --排除这个统计信息

DROP STATISTICS dbo.TBusRetail.[IdxRefNoOpDate]; --排除这个统计信息

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000016_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000015_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000003_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_PayWay_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_Opr_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_Charger_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_RefNo_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_TicketAmount_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_ChargeDate_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_TicketFAmount_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_PayAmount_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_Accepted_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_OpDate_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_Checked_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_CheckDate_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_HangUp_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_TPayAmount_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_Remark_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_RetailType_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_AcceptDate_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_IfNetRetail_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_DisModified_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_Dealed_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_VipScale_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000024_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000032_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000033_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000031_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000030_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_0000002C_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_0000002B_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_0000002A_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000029_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000028_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000027_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000026_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000025_58BCECDB]

DROP STATISTICS dbo.TBusRetail.[_WA_Sys_00000018_58BCECDB]

上一次遇到的问题在这里:消息 8134,级别 16,状态 1,第 1 行 遇到以零作除数错误

 

参考资料:

https://support.microsoft.com/en-us/help/2498796/fix-an-access-violation-may-occur-when-you-update-the-statistics-of-a

SQL Server 更新统计信息出现严重错误,应放弃任何可能产生的结果的更多相关文章

  1. SQL SERVER的统计信息

    1 什么是统计信息     统计信息 描述了 表格或者索引视图中的某些列的值 的分布情况,属于数据库对象.根据统计信息,查询优化器就能评估查询过程中需要读取的行数及结果集情况,同时也能创建高质量的查询 ...

  2. Sql Server优化---统计信息维护策略

    本位出处:http://www.cnblogs.com/wy123/p/5748933.html 首先解释一个概念,统计信息是什么: 简单说就是对某些字段数据分布的一种描述,让SQL Server大概 ...

  3. SQL Server 中统计信息直方图中对于没有覆盖到谓词预估以及预估策略的变化(SQL2012-->SQL2014-->SQL2016)

    本位出处:http://www.cnblogs.com/wy123/p/6770258.html 统计信息写过几篇了相关的文章了,感觉还是不过瘾,关于统计信息的问题,最近又踩坑了,该问题虽然不算很常见 ...

  4. SQL Server 查找统计信息的采样时间与采样比例

    有时候我们会遇到,由于统计信息不准确导致优化器生成了一个错误的执行计划(或者这样表达:一个较差的执行计划),从而引起了系统性能问题.那么如果我们怀疑这个错误的执行计划是由于统计信息不准确引起的.那么我 ...

  5. SQL Server 等待统计信息基线收集

    背景 我们随时监控每个服务器不同时间段的wait statistics ,可以根据监控信息大概判断什么时候开始出现异常,相当于一个wait statistics基线收集,还可以具体分析占比高的等待类型 ...

  6. c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程

    c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...

  7. SQL2008R2的 遍历所有表更新统计信息 和 索引重建

    [2.以下是更新统计信息] DECLARE UpdateStatisticsTables CURSOR READ_ONLY FOR SELECT sst.name, Schema_name(sst.s ...

  8. 为准确生成执行计划更新统计信息-analyze与dbms_stats

    如果我们想让CBO利用合理利用数据的统计信息,正确判断执行任何SQL查询时的最快途径,需要及时的使用analyze命令或者dbms_stats重新统计数据的统计信息. 例如索引跳跃式扫描(INDEX ...

  9. SQLServer 创建dtsx包更新统计信息(示例)

    http://blog.csdn.net/kk185800961/article/details/43816177(转载) 1 . 打开Microsoft Visual Studio 创建 integ ...

随机推荐

  1. [Swift]LeetCode566. 重塑矩阵 | Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  2. [Swift]LeetCode1002. 查找常用字符 | Find Common Characters

    Given an array A of strings made only from lowercase letters, return a list of all characters that s ...

  3. Oracle常用语句

    Oracle数据库常用sql语句 ORACLE 常用的SQL语法和数据对象一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, ...

  4. openstack快速安装之packstack

    最简单的openstack安装方式之packstack 一.环境准备 我们安装的是all-in-one环境的openstack,测试机IP:192.168.1.10 [root@openstack ~ ...

  5. Kubernetes 笔记 06 豌豆荚之旅(一)

    本文首发于我的公众号 Linux云计算网络(id: cloud_dev),专注于干货分享,号内有 10T 书籍和视频资源,后台回复「1024」即可领取,欢迎大家关注,二维码文末可以扫. Hi,大家好, ...

  6. 解决classNotFound的问题的思路

    用Ctrl+Shift+t可以查看class,对于报错信息,我们把没有找到的class放到查找框里进行查看,找到之后把这个jar包放到WEB-INF的lib目录下,build path一下就可以了. ...

  7. BBS论坛(一)

    1.1.项目结构搭建 (1)创建flask项目Perfect_bbs,然后搭建项目结构如下: (2)构建蓝图 cms/views.py # cmd/views.py from flask import ...

  8. 利用jmap和MAT等工具查看JVM运行时堆内存

    jmap JDK自带了一些工具可以帮助我们查看JVM运行的堆内存情况,常用的是jmap命令 jmap -heap <pid> 打印堆的使用情况 那么,从这个输出中我们也可以大致看出堆的结构 ...

  9. Owin学习笔记(二) 中间件开发

    Owin中也有类似于ASP.NET的管道,以前在做ASP.NET项目的时候,可以制作很多不同功能HttpHandler或者HttpModule并注册在Web.config中重复使用.在Owin的管道中 ...

  10. 学习springboot

    一般而言,写个Javaweb应用搭建环境都可能要几十分钟,下载个tomcat服务器,再加上各种xml配置等等,很烦躁,而且每个web应用的配置还差不多,都是什么web.xml,application. ...