简体   繁体   English

SQL Server:INSERT / UPDATE / DELETE失败,因为以下SET选项具有错误的设置:'QUOTED_IDENTIFIER'

[英]SQL Server: INSERT/UPDATE/DELETE failed because the following SET options have incorrect settings: ‘QUOTED_IDENTIFIER’

I have this rather awkward problem: 我有一个比较尴尬的问题:

For two weeks now, whenever after I've updated/created stored procedures using my SQL scripts, when these stored procedures are run, they fail with above error. 现在有两个星期,每当我使用SQL脚本更新/创建存储过程后,运行这些存储过程时,它们都会因上述错误而失败。

Other posts dealing with this problem didn't help in my case. 其他有关此问题的帖子对我的情况没有帮助。

Here's a number of parameters, helping to exclude common solutions which do not apply in my case: 以下是一些参数,有助于排除在我的情况下不适用的常见解决方案:

  1. My stored procedure scripts work flawlessly on my laptop (SQL Server 2012, Windows Server 2008 R2). 我的存储过程脚本可在笔记本电脑(SQL Server 2012,Windows Server 2008 R2)上完美运行。

  2. My stored procedure scripts correctly create stored procedures on any other machine (which is our build machine, with SQL Server 2012 installed; our TEST server, with SQL Server 2005 installed, and our PROD server, with SQL Server 2005 installed). 我的存储过程脚本可以在任何其他计算机(安装了SQL Server 2012的构建计算机;安装了SQL Server 2005的TEST服务器和安装了SQL Server 2005的PROD服务器)上正确创建存储过程。 However, the stored procedures won't run on any other machine than mine. 但是,存储过程将不会在我的任何其他机器上运行。

  3. I'm using a database backup of our production SQL Server (SQL Server 2005) on my machine (like any other machine here does). 我正在机器上使用生产SQL Server(SQL Server 2005)的数据库备份(就像这里的任何其他机器一样)。

  4. Even the most basic stored procedure fails (eg DELETE myTable WHERE ID = @delID ). 即使最基本的存储过程DELETE myTable WHERE ID = @delID失败(例如, DELETE myTable WHERE ID = @delID )。

  5. On every SQL Server installation I've checked, quoted identifier is set to OFF (!), both on server and on database level. 在我检查过的每个SQL Server安装中,在服务器级别和数据库级别上,带引号的标识符都设置为OFF (!)。 So why do my stored procedures all of a sudden require to have this option set to ON ? 那么,为什么我的存储过程突然需要将此选项设置为ON

  6. I'm using SQLCMD to run my scripts. 我正在使用SQLCMD运行脚本。 This gives me an option to dynamically set the server instance's database name in the USE statement. 这给了我一个选择,可以在USE语句中动态设置服务器实例的数据库名称。

  7. My scripts only contain a USE statement and right after the ALTER PROCEDURE ; 我的脚本仅在ALTER PROCEDURE之后包含USE语句; or alternatively IF EXISTS (...) DROP PROCEDURE ... GO; CREATE PROCEDURE ... 或者, IF EXISTS (...) DROP PROCEDURE ... GO; CREATE PROCEDURE ... IF EXISTS (...) DROP PROCEDURE ... GO; CREATE PROCEDURE ...

This all worked for years now, but suddenly, since two weeks ago, stored procedures created with my scripts suddenly fail. 这一切已经工作了好几年,但是自两个星期前以来,突然用我的脚本创建的存储过程突然失败了。

I know that I could manually set QUOTED_IDENTIFIER to ON in my scripts - but I don't want to. 我知道我可以在脚本中手动将QUOTED_IDENTIFIER设置为ON但我不想这样做。 There is something wrong here. 这里有问题。 I want to know what that problem is. 我想知道那是什么问题。

What's happening here? 这里发生了什么事?

SQLCMD sets the QUOTED_IDENTIFIER option to OFF by default. 默认情况下,SQLCMD将QUOTED_IDENTIFIER选项设置为OFF。 You can change it with -I option. 您可以使用-I选项进行更改。

Could it be that your stored procedure is now doing something on a table that has had an index added? 可能是您的存储过程正在对已添加索引的表执行某项操作吗? I've had the same issue, and it's due to a new index on a computed column. 我遇到了同样的问题,这是由于计算列上有新索引。

暂无
暂无

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

相关问题 SQL 查询通知 - 更新失败,因为以下 SET 选项的设置不正确:'QUOTED_IDENTIFIER' - SQL Query Notifications - UPDATE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER' Docker CREATE INDEX中的SQL Server失败,因为以下SET选项的设置不正确:'QUOTED_IDENTIFIER' - SQL Server in Docker CREATE INDEX failed because the following SET options have incorrect settings: ‘QUOTED_IDENTIFIER’ INSERT 失败,因为以下 SET 选项的设置不正确:'QUOTED_IDENTIFIER' - INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER' `bcp in` 失败并显示“插入失败,因为以下 SET 选项设置不正确:'QUOTED_IDENTIFIER'” - `bcp in` fails with "INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'" 删除所有表时出错“DELETE 失败,因为以下 SET 选项的设置不正确:'QUOTED_IDENTIFIER'” - Error deleting all tables "DELETE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'" INSERT失败,因为以下SET选项的设置不正确:“ ARITHABORT”。 - INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'. UPDATE失败,因为以下SET选项的设置不正确:'ARITHABORT' - UPDATE failed because the following SET options have incorrect settings: 'ARITHABORT' 过滤的唯一索引导致更新由于错误的“ QUOTED_IDENTIFIER”设置而失败 - Filtered Unique Index causing UPDATE to fail because incorrect 'QUOTED_IDENTIFIER' settings SQL 服务器 QUOTED_IDENTIFIER 更新时出错 - SQL Server QUOTED_IDENTIFIER Error On UPDATE Laravel TALL sql server Illuminate/Database/Connection.php General error 20018 UPDATE failed because 以下SET选项设置不正确 - Laravel TALL sql server Illuminate/Database/Connection.php General error 20018 UPDATE failed because the following SET options have incorrect settings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM