简体   繁体   English

计划SQL查询ERROR -Set QUOTED IDENTIFIER

[英]Schedule SQL query ERROR -Set QUOTED IDENTIFIER

I have tried to schedule an sql query it failed,and the error that I got was, 我试图安排一个失败的SQL查询,而我得到的错误是,

Update failed because the following SET 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.[SQLSTATE 42000](Error 1934).

I have this solution 我有这个解决方案

Add SET QUOTED_IDENTIFIER ON
before your UPDATE statements in SQL Job step.

But, what does SET QUOTED_IDENTIFIER ON do ? 但是, SET QUOTED_IDENTIFIER ON什么作用? Could someone explain it to me? 有人可以向我解释吗?

Thanks 谢谢

EDIT 1; 编辑1; I tried the above , the scheduled query executed , but did not change an of the fields anything? 我尝试了上述操作,执行了预定的查询,但没有更改任何字段?

The Query is use; 查询被使用;

SET QUOTED_IDENTIFIER ON
update dbo.myTable
set name=[dbo].[functName](name);

If I run a normal UPDATE query , 如果我运行普通的UPDATE查询,

update dbo.myTable set name=[dbo].[functName](name);

It works, and fields are changed. 它有效,并且字段已更改。

Why would it not work in the scheduled query? 为什么在预定查询中不起作用?

Thanks 谢谢

It specifies how SQL Server will be treating your data which you have defined in Single Quotes and Double Quotes. 它指定SQL Server将如何处理您在单引号和双引号中定义的数据。 The MSDN gives you the answer: MSDN为您提供了答案:

Causes SQL Server to follow the ISO rules regarding quotation mark delimiting identifiers and literal strings. 使SQL Server遵循有关引号定界标识符和文字字符串的ISO规则。 Identifiers delimited by double quotation marks can be either Transact-SQL reserved keywords or can contain characters not generally allowed by the Transact-SQL syntax rules for identifiers. 用双引号引起来的标识符可以是Transact-SQL保留关键字,也可以包含Transact-SQL语法规则通常不允许使用的字符作为标识符。

Also check the Remarks section which provides the details about ON and OFF. 还要检查“ 备注”部分,其中提供了有关“打开”和“关闭”的详细信息。

When SET QUOTED_IDENTIFIER is ON, identifiers can be delimited by double quotation marks, and literals must be delimited by single quotation marks. 当SET QUOTED_IDENTIFIER为ON时,标识符可以用双引号分隔,而文字必须用单引号分隔。 When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers. 当SET QUOTED_IDENTIFIER为OFF时,标识符不能加引号,并且必须遵循所有Transact-SQL标识符规则。 For more information, see Database Identifiers. 有关更多信息,请参见数据库标识符。 Literals can be delimited by either single or double quotation marks................ 文字可以用单引号或双引号分隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM