SQL Server - 使用带引号的标识符 ON 和 OFF 以及 Getdate()
我的脚本 SQL 有问题,请帮助我。
例如:
我有一个插入语句:
INSERT INTO CUSTOMER (Code, Date) VALUES (1, GETDATE());
当我执行此插入时,返回以下消息:
“消息 1934,级别 16,状态 1,服务器 HENRIQUE-PC,第 5 行插入失败 因为以下 SET 选项有 不正确的设置:'QUOTED _IDENTIFIER'。验证 SET 选项是否正确用于 索引视图和/或索引 计算列和/或过滤列 索引和/或查询通知 和/或 XML 数据类型方法和/或 空间索引操作。”。
现在,当我使用 SET QUOTED_IDENTIFIER ON 时,我的插入成功执行。
例如:
SET QUOTED_IDENTIFIER OFF
GO
INSERT INTO CUSTOMER (Code, Date) VALUES (1, GETDATE());
SET QUOTED_IDENTIFIER ON
GO
(1 行受影响)
GETDATE()
和 QUOTED IDENTIFIER
之间有什么关系?
为什么在这种情况下我需要使用QUOTED IDENTIFIER?
我相信这是因为 getdate 。为什么?
谢谢。
恩里克·梅利西奥
I have a problem with my script SQL, please help me.
Ex:
I have a insert statments:
INSERT INTO CUSTOMER (Code, Date) VALUES (1, GETDATE());
When I execute this insert, retuns the follow message:
"Msg 1934, Level 16, State 1, Server
HENRIQUE-PC, Line 5 INSERT 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 notificatio ns
and/or XML data type methods and/or
spatial index operations.".
Now, when I used SET QUOTED_IDENTIFIER ON
, my insert is executed with success.
Ex:
SET QUOTED_IDENTIFIER OFF
GO
INSERT INTO CUSTOMER (Code, Date) VALUES (1, GETDATE());
SET QUOTED_IDENTIFIER ON
GO
(1 row(s) affected)
What relationship betwhen GETDATE()
and QUOTED IDENTIFIER
?
Why I need to use QUOTED IDENTIFIER in this case?
I believe it is because of getdate. Why?
Thanks.
Henrique Melicio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Henrique,
您收到该错误的原因与
GETDATE()
无关,它与CUSTOMER
表中列的索引有关。 SQL Server 2008 的SET 语句 (Transact-SQL)
文档中的这段内容更详细地解释了该问题:Henrique,
The reason you're getting that error is not related to
GETDATE()
, it has to do with indexes on columns from yourCUSTOMER
table. This bit from SQL Server 2008'sSET Statements (Transact-SQL)
document explains the issue in more detail: