简体   繁体   English

删除所有表时出错“DELETE 失败,因为以下 SET 选项的设置不正确:'QUOTED_IDENTIFIER'”

[英]Error deleting all tables "DELETE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'"

I have a script to delete all tables in my database that looks like this:我有一个脚本来删除我的数据库中的所有表,如下所示:

-- Disable all constraints
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT all'

-- Disable all triggers 
EXEC EnableAllTriggers @Enable = 0

-- Delete data in all tables
EXEC sp_MSForEachTable 'DELETE FROM ?'
 
-- Dnable all constraints
EXEC sp_MSForEachTable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all'
 
-- Reseed identity columns
EXEC sp_MSForEachTable 'DBCC CHECKIDENT (''?'', RESEED, 0)'

-- Enable all triggers
EXEC EnableAllTriggers @Enable = 1

When it hits the DELETE line I get this error for a few of the tables:当它碰到 DELETE 行时,我收到了一些表的这个错误:

DELETE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. DELETE 失败,因为以下 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 数据类型方法和/或空间索引操作。

I don't have any indexed views, all foreign keys and triggers are disabled, so I don't know what is causing this error.我没有任何索引视图,所有外键和触发器都被禁用,所以我不知道是什么导致了这个错误。 Any ideas?有任何想法吗?

Add the SET options to the delete call.将 SET 选项添加到删除调用中。

These still apply to the other items mentioned in the error, even though you disabled FKs.即使您禁用了 FK,这些仍然适用于错误中提到的其他项目。

This will work around any saved or environment settings这将解决任何已保存或环境设置

Edit, after comment编辑,评论后

EXEC sp_MSForEachTable 'SET QUOTED_IDENTIFIER ON; DELETE FROM ?'

暂无
暂无

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

相关问题 SQL Server:INSERT / UPDATE / DELETE失败,因为以下SET选项具有错误的设置:'QUOTED_IDENTIFIER' - SQL Server: INSERT/UPDATE/DELETE 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' SQL 查询通知 - 更新失败,因为以下 SET 选项的设置不正确:'QUOTED_IDENTIFIER' - SQL Query Notifications - UPDATE 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'" 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’ UPDATE失败,因为以下SET选项的设置不正确:'ARITHABORT' - UPDATE failed because the following SET options have incorrect settings: 'ARITHABORT' INSERT失败,因为以下SET选项的设置不正确:“ ARITHABORT”。 - INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'. 解决方法“ SELECT失败,因为以下SET选项具有错误的设置:'ANSI_PADDING'。 ”错误 - How to workaround “SELECT failed because the following SET options have incorrect settings: 'ANSI_PADDING'. ” error 由于以下SET选项的设置不正确,导致由于INSERT而出错 - Getting Error as INSERT failed because the following SET options have incorrect settings 过滤的唯一索引导致更新由于错误的“ QUOTED_IDENTIFIER”设置而失败 - Filtered Unique Index causing UPDATE to fail because incorrect 'QUOTED_IDENTIFIER' settings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM