SQL Server 2000:更新语句上的"子查询返回多个值"

时间:2020-03-06 14:52:46  来源:igfitidea点击:

我正在尝试做一个简单的更新。我已经做过数千遍了。

update articles
set department = 60
where type = 'Top Story'

今天我遇到一个奇怪的错误。

Describe Error: Failed to retrieve
  execution plan: Subquery returned more
  than 1 value. This is not permitted
  when the subquery follows =, !=, <, <=
  , >, >= or when the subquery is used
  as an expression.
  
  Warnings: --->     W (1): The
  statement has been terminated.
            <--- 
  
  1559 record(s) affected

update语句中没有子查询。这是怎么回事?

解决方案

最有可能在表上有一个触发器,并且该错误发生在触发器中,而不是在实际SQL语句中。

我进一步打赌,触发器假定插入或者删除特殊表将仅具有单行(实际上,在批量更新中就不是这种情况,就像我们正在执行的那样),这会引起问题。