我不知道为什么会收到此错误: -
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.
我试图运行此查询: -
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
答案 0 :(得分:6)
您要更新的其中一个表是否有触发器?如果是,则可能包含具有多个值的子查询。
我个人认为在进行插入或更新时关闭检查约束是一种非常糟糕的做法。它们存在是有原因的,如果您的数据不符合这些约束,则不应按原样插入,或者需要针对新条件调整约束。如果将来更新记录,它也会产生问题。
答案 1 :(得分:0)
看起来你需要一个分号来结束这个陈述:
UPDATE Test
SET RefID = '05f6c6b4-63ff-45b2-a5e2-920d5dce3e45'
WHERE RefID = '05e6c6b4-63ff-45b2-a5e2-920d5dce3e45';
UPDATE RefPhysician
SET RefID = '05f6c6b4-63ff-45b2-a5e2-920d5dce3e45' ,
SpecID = NULL ,
RefLastName = 'DR. BRAD DIBBLE' ,
RefFirstName = 'First Name' ,
RefMiddleName = NULL ,
RefPhone1 = '613444444' ,
RefPhone2 = 'print,read,866,1' ,
RefFax = '6476476464' ,
RefEmail = 'xxxxxxx@hotmail.ca'
WHERE RefID = '05e6c6b4-63ff-45b2-a5e2-920d5dce3e45' ; <-- semicolon