是什么导致“子查询返回了 1 个以上的值..."?错误?

What is causing amp;quot;Subquery returned more than 1 value...amp;quot; error?(是什么导致“子查询返回了 1 个以上的值...?错误?)
本文介绍了是什么导致“子查询返回了 1 个以上的值..."?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我不知道为什么会出现此错误:-

I dont have any idea why am i getting this error :-

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

我正在尝试运行此查询:-

I was trying to run this query:-

ALTER TABLE Test1 NOCHECK CONSTRAINT ALL
ALTER TABLE Test2 NOCHECK CONSTRAINT ALL


UPDATE Test1 
SET ID= '05f6c6b4-63ff-45b2-a5e2-920d5dce3e45' 
WHERE ID = '05e6c6b4-63ff-45b2-a5e2-920d5dce3e45'; 
UPDATE Test2 
SET ID = '05f6c6b4-63ff-45b2-a5e2-920d5dce3e45' ,
SpecID = NULL ,
RefLastName = 'Dummy' ,
RefFirstName = 'First Name' ,
RefMiddleName = NULL ,
RefPhone1 = '111444444' ,
RefPhone2 = '2121222' ,
RefFax = '222222' ,
RefEmail = 'xxxxxxx@hotmail.ca' 
WHERE 
RefID = '05e6c6b4-63ff-45b2-a5e2-920d5dce3e45' 

ALTER TABLE Test1 WITH CHECK CHECK CONSTRAINT ALL
ALTER TABLE Test2 WITH CHECK CHECK CONSTRAINT ALL

推荐答案

您要更新的表之一是否有触发器?如果是,则很可能它包含具有多个值的子查询.

Does one of the tables you are updating have a trigger? If it does, likely it contains a subquery with more than one value.

我个人认为在执行插入或更新时关闭检查约束是一种非常糟糕的做法.它们存在是有原因的,如果您的数据不符合这些约束,则不应按原样插入,或者需要针对新条件调整约束.如果将来更新记录,它也会产生问题.

Personally I find it a very bad practice to turn check constraints off when doing inserts or updates. They are there for a reason and if your data doesn't meet those constraints, it should not be inserted as is or the constraint needs to be adjusted for new conditions. It can also create problems if the records is updated in the future.

这篇关于是什么导致“子查询返回了 1 个以上的值..."?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Query with t(n) and multiple cross joins(使用 t(n) 和多个交叉连接进行查询)
Unpacking a binary string with TSQL(使用 TSQL 解包二进制字符串)
Max rows in SQL table where PK is INT 32 when seed starts at max negative value?(当种子以最大负值开始时,SQL 表中的最大行数其中 PK 为 INT 32?)
Inner Join and Group By in SQL with out an aggregate function.(SQL 中的内部连接和分组依据,没有聚合函数.)
Add a default constraint to an existing field with values(向具有值的现有字段添加默认约束)
SQL remove from running total(SQL 从运行总数中删除)