sql-server – 从sp_msForEachTable运行时,由于QUOTED_IDENTIFIE
当我尝试在表上重建索引时:
ALTER INDEX ALL ON [dbo].[Allocations] REBUILD 工作正常. 但是当我打电话时 EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD' 我到达同一张桌子,它失败了:
并确认它是相同的表: 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,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(''?'')' 工作良好! 解决方法针对每个存储过程存储带引号的标识符设置,sp_MSforeachtable将其定义为OFF.但是,您可以解决此问题 – 在执行重新索引之前将其设置为ON:create table dbo.T ( ID int not null,constraint PK_T PRIMARY KEY (ID) ) go create view dbo.V ( ID) with schemabinding as select ID from dbo.T go create unique clustered index IX_V on dbo.V(ID) go ALTER INDEX ALL ON dbo.V REBUILD --Fine go exec sp_MSforeachtable 'ALTER INDEX ALL ON ? REBUILD' --Errors go exec sp_MSforeachtable 'SET QUOTED_IDENTIFIER ON; ALTER INDEX ALL ON ? REBUILD' --Fine
当然,插入关于sp_MSforeachtable未记录的常见警告,因此您不能依赖其任何稳定的行为.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Audit login 与 Audit logout
- SqlServer 时间函数的应用(DateDiff )
- 如何将短文本字符串存储到SQL Server数据库中?
- 从现有数据库模式生成Hibernate hbm xml文件和实体类
- mysql in语句子查询效率慢的优化技巧示例
- 如何在SQL中选择所有值并隐藏NULL值?
- sql-server – SQL’flora’数据类型,当以XML格式输出时,会
- 找不到SQL Server management studio的问题
- sqlserver2008 端口占用 8080 ReportingServicesService.ex
- 创建单个sqlserver sde服务