当我尝试重建一个表上的索引时:
ALTER INDEX ALL ON [dbo].[Allocations] REBUILD
那个很好用。
但是当我调用时
EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD'
我遇到了同样的表格,并且出现了以下错误:
消息1934,级别16,状态1,行2
ALTER INDEX失败,因为以下SET选项设置不正确:'QUOTED_IDENTIFIER'。请验证SET选项是否正确用于索引视图和/或计算列上的索引和/或过滤索引和/或查询通知和/或XML数据类型方法和/或空间索引操作。
并且确认这是相同的表格:
EXECUTE sp_msForEachTable 'print ''Rebuilding ?'';
ALTER INDEX ALL ON ? REBUILD;
PRINT '' Done ?'''
这将给出结果:
Rebuilding [dbo].[SystemConfiguration]
Done [dbo].[SystemConfiguration]
Rebuilding [dbo].[UserGroups]
Done [dbo].[UserGroups]
Rebuilding [dbo].[Groups]
Done [dbo].[Groups]
Rebuilding [dbo].[UserPermissions]
Done [dbo].[UserPermissions]
Rebuilding [dbo].[AllocationAdmins]
Done [dbo].[AllocationAdmins]
Rebuilding [dbo].[Allocations]
Msg 1934, Level 16, State 1, Line 2
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.
我做错了什么?
注意:
EXECUTE sp_msForEachTable 'DBCC DBREINDEX(''?'')'
运行良好!