sql - 如何更改数据库中每个表的索引

标签 sql sql-server-2008 sql-server-2008-r2

我使用 SQL Server 2008 R2,我需要为数据库中的每个表重建索引

使用这个脚本,我收到一个错误

USE myDb
GO

EXEC sp_MSForEachTable 'ALTER INDEX ALL ON ? REBUILD'

错误:

ALTER INDEX failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.



知道如何修复它吗?谢谢

最佳答案

SQL Fool (Michelle Ufford) 有一个很棒的脚本可以为您执行此操作 - 所有这些都已完成并经过许多用户的良好测试。

这是一项伟大的工作 - 它允许您定义碎片级别

  • 什么都不做
  • 重组索引
  • 重建索引

  • 不要重新发明轮子 - just go see and use the script!

    关于sql - 如何更改数据库中每个表的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8326595/

    相关文章:

    sql - 用户生成的 SQL 查询

    sql - 如何将SQL Server 2012数据库还原到SQL Server 2008 R2?

    sql - 将 VARCHAR 转换为 SMALLDATETIME 作为 UPDATE 语句的一部分

    mysql - 在没有设置任何数据库的情况下,如何将 CSV 文件转换为基于 Web 的 SQL 数据库表?

    sql - 如何选择由其他一些列值组成的列

    MySQL 主键 : UUID/GUID vs BIGINT (timestamp+random)

    sql - 查看服务器上运行的所有 SQL 查询的列表

    sql-server-2008 - 按函数返回表类型

    sql - 哪个更快/更好 : UPDATE WHERE IN or MERGE?

    sql - 在单独的列中添加查询输出的最小值