简体   繁体   English

SQL 服务器 QUOTED_IDENTIFIER 更新时出错

[英]SQL Server QUOTED_IDENTIFIER Error On UPDATE

I am getting the following error on a very basic update query when it is executed as job in SQL Server 2008. It runs as expected when I run it manually in SSMS.在 SQL Server 2008 中作为作业执行时,我在一个非常基本的更新查询中遇到以下错误。当我在 SSMS 中手动运行它时,它按预期运行。 Can somebody help me figure out what is going on to cause this?有人可以帮我弄清楚这是怎么回事吗? The database settings have Quoted Identifiers Enabled set to False.数据库设置已将 Quoted Identifiers Enabled 设置为 False。 I have tried adding SET QUOTED_IDENTIFIERS TRUE to the job and that did not work either.我已经尝试将 SET QUOTED_IDENTIFIERS TRUE 添加到作业中,但这也不起作用。

UPDATE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. UPDATE 失败,因为以下 SET 选项的设置不正确:'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.验证 SET 选项是否适用于索引视图和/或计算列上的索引和/或过滤索引和/或查询通知和/或 XML 数据类型方法和/或空间索引操作。

The query is as follows (table and column names have been changed to protect the innocent)查询如下(表名和列名已更改,以保护无辜)

UPDATE Table1
SET Column1 = 'C'
WHERE col_status = 'A' AND emp_number
IN (SELECT emp_number
FROM Table2
WHERE emp_status = 'T') 

You need add below two set statements while updating table1.您需要在更新 table1 时添加以下两个 set 语句。

You can use join directly to update table1.可以直接使用join来更新table1。

SET QUOTED_IDENTIFIER ON;

UPDATE T1
SET T1.Column1 = 'C'
FROM Table1 AS T1
INNER JOIN Table2 AS T2 ON T2.emp_number = T1.emp_number
AND T1.col_status = 'A'
AND T2.emp_status = 'T';

SET QUOTED_IDENTIFIER OFF;

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

相关问题 SQL SERVER 和 SET ANSI_NULLS ON, SET QUOTED_IDENTIFIER ON - SQL SERVER and SET ANSI_NULLS ON, SET QUOTED_IDENTIFIER ON SQL Server 2008 SET QUOTED_IDENTIFIER OFF问题 - SQL Server 2008 SET QUOTED_IDENTIFIER OFF problem SQL 查询通知 - 更新失败,因为以下 SET 选项的设置不正确:'QUOTED_IDENTIFIER' - SQL Query Notifications - UPDATE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER' 由于使用了XML / ANSI_NULLS,QUOTED_IDENTIFIER选项,SQL Server存储过程失败 - SQL Server Stored Procedure Fails due to use of XML/ ANSI_NULLS, QUOTED_IDENTIFIER options SQL Server代理发出的第一条语句将quoted_identifier设置为off - First statement issued by SQL Server Agent sets quoted_identifier off EXEC和设置Quoted_Identifier - EXEC and Set Quoted_Identifier ANSI_NULLS和QUOTED_IDENTIFIER行为 - ANSI_NULLS and QUOTED_IDENTIFIER Behavior 过滤的唯一索引导致更新由于错误的“ QUOTED_IDENTIFIER”设置而失败 - Filtered Unique Index causing UPDATE to fail because incorrect 'QUOTED_IDENTIFIER' settings ANSI_NULLS 和 QUOTED_IDENTIFIER 杀死了一些东西。 它们是为了什么? - ANSI_NULLS and QUOTED_IDENTIFIER killed things. What are they for? 事务复制不复制 SET QUOTED_IDENTIFIER - Transactional Replication does not replicate SET QUOTED_IDENTIFIER
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM