简单更新查询返回错误[512][S0001]:子查询返回的值超过1



我正试图用这样一个简单的查询来更新表上的一列:

update tes_off_ven
set delivery_date=null
where company_id ='A01' and  registration_year = 2022 and registration_number = 183

但是SqlServer返回以下错误:

SQL Error [512] [S0001]: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

只有当我尝试更新特定的记录,但与另一个记录配合良好时,才会返回错误,例如使用以下where子句:

where company_id ='A01' and  registration_year = 2022 and registration_number = 182

但还有另一种奇怪的行为。。。没有任何where子句的超简单/超大量更新查询

update tes_off_ven
set delivery_date=null 

工作良好!

tes_off_ven表的主键中有三个字段company_idregistration_yearregistration_number,许多表通过这些字段与tes_off_ven链接。

如果截断所有tes_off_ven链接表,则更新查询工作正常。

正如@Dan Guzman和@Delta32000所建议的,问题是由触发器引起的。

最新更新