- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试在表上重建索引时:
ALTER INDEX ALL ON [dbo].[Allocations] REBUILD
效果很好。
但是当我打电话时
EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD'
我到达同一张表,但失败了:
<小时/>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 '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(''?'')'
工作很好!
最佳答案
引用的标识符设置针对每个存储过程进行存储,并且 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
<小时/>
<小时/>When a stored procedure is created, the
SET QUOTED_IDENTIFIER
andSET ANSI_NULLS
settings are captured and used for subsequent invocations of that stored procedure.
当然,请插入有关 sp_MSforeachtable
未记录的常见警告,因此您不能依赖其任何稳定的行为。
对于DBCC DBREINDEX
- 所有的赌注都失败了。 DBCC
生活在它自己的小而定制化的代码世界中。但是,当然, future 的工作也不应该依赖它:
This feature will be removed in a future version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible. Use
ALTER INDEX
instead.
关于sql-server - 从 sp_msForEachTable 运行时,由于 QUOTED_IDENTIFIER,ALTER INDEX 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12674664/
我们刚刚遇到了一个问题,我们的存储过程之一抛出了错误; SELECT failed because the following SET options have incorrect settings:
我在 的帮助下实现了一个机制SqlDependency 这会提醒我特定数据库表中的任何更改。 但这破坏了我现有的功能,我正在更新已在其上实现 SqlDependency 的数据库表。 我收到以下错误:
我尝试在 PHPMyAdmin 中执行 SQL 语句,但收到一条错误消息: Error #1193 - Unknown system variable 'QUOTED_IDENTIFIER' SQL语
我目前正在使用 2008-r2 服务器上的旧式数据库,该数据库使用了很多创建时将带引号的标识符设置为关闭的对象。 我主要看这几种: CHECK_CONSTRAINT DEFAULT_CONSTRAIN
我有一个存储过程,在里面我有一个分页查询,它根据我所在的页面返回一组结果。 我有 DECLARE @Products TABLE()... then INSERT INTO @Products SEL
昨天,我在 MSSQL 2008 数据库中的 View 上添加了一些索引。之后,似乎所有存储过程都需要在 QUOTED_IDENTIFIER 设置为 ON 的情况下运行,即使是那些不使用相关 View
注意:我检查了 Understanding QUOTED_IDENTIFIER它没有回答我的问题。 我让我的 DBA 运行我在 Prod 服务器上创建的索引(他们查看并批准了它)。 它像我想要的那样加
所以我一直在创建脚本的时候盲目地使用ansi_nulls on,quoted_identifier on,因为sqlserver在脚本化对象的时候会自动生成它们.. 我真的没有时间关心这些琐碎的废话
有没有办法识别对象是在 SET QUOTED_IDENTIFIER 打开还是关闭的情况下创建的? (不仅是这个设置选项,我还在寻找一个脚本来识别与该对象关联的所有 ANSI 设置) 这是对 staac
我安装了 Visual Studio 2012,并安装了 SSDT 版本 11.1.20627.0。 一直困扰我的问题之一是我在 SSDT 项目中尝试使用模式比较将其推送到服务器时的所有存储过程。 S
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
我有一个存储过程,它接受一个 XML 参数并将数据插入到多个表中。如果我使用 SSMS 查询窗口将存储过程运行到数据库中,一切正常。但是,我们有一个自定义安装程序,用于将存储过程部署到数据库,当使用它
任何人都可以对此提供见解吗? 我开发了一个使用 XML 数据类型的导入过程。在通过 import sProc 将数据插入表后,我运行另一个过程以使用导入的表更新另一个表。 如果使用 SET QUOTE
我在更新存储过程时遇到问题。错误是: UPDATE failed because the following SET options have incorrect settings: 'QUOTED_
在执行存储过程时,我们有时会收到以下消息,之后无需任何更改,删除并重新执行存储过程,它就可以正常工作。 DBCORE INSERT failed because the following SET o
喜欢others previously ,今天在我的 SQL 日志中我可以看到计划的作业由于错误 1934 而无法执行。 ALTER INDEX failed because the followin
当我尝试在表上重建索引时: ALTER INDEX ALL ON [dbo].[Allocations] REBUILD 效果很好。 但是当我打电话时 EXECUTE sp_msForEachTabl
当我右键单击/修改时,如何防止 SQL Management Studio (10.50.2500.0) 将其添加到每个存储过程的开头? SET ANSI_NULLS ON GO SET QUOTED
我有一个脚本来删除数据库中的所有表,如下所示: -- Disable all constraints EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CON
我有一个 SQL Server Dockerfile,我的 import-data.sh 从 sql-data 文件夹导入 *.sql 文件。如果我从 Datagrip 之类的工具运行 *.sql 文
我是一名优秀的程序员,十分优秀!