問題描述
我不知道為什么會出現此錯誤:-
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 個以上的值..."?錯誤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!