当我尝试在表上重建索引时:
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(''?'')'
工作正常!