问题描述
以下内容让我抓狂,请帮帮我!
The following is driving me nuts, please help me!
作为运行 UPDATE 语句(T-SQL;SQL Server 2012)之前的检查,我运行:
As a check before running an UPDATE statement (T-SQL; SQL Server 2012) I run:
select *
from Treatment_Day42
where td42pinit = 'J M' and td42pid = 'ADA';
如我所料,返回了 1 行.
and I get 1 row returned, as I expect.
然而,运行
update Treatment_Day42 set td42pid = 'ADA252'
where td42pinit = 'J M' and td42pid = 'ADA';
影响四条记录,而不是像在具有完全相同的 WHERE 子句的 select 语句中那样的一条记录.我得到了 select 返回的行加上其他 3 行,其中 td42pid = ADA458、ADA671 和 ADA658.
affects four records, not one as in the select statement with the exact same WHERE clause. I get the row returned by the select plus 3 other rows where td42pid = ADA458, ADA671 and ADA658.
为什么 UPDATE 影响的行数超出我的预期?
Why is the UPDATE affecting more rows than I intend it to?
谢谢.
克莱门斯
推荐答案
表上的触发器可以做到这一点.您是否检查过现有的触发器?
A trigger on the table could do this. Have you checked for an existing trigger?
这篇关于T-SQL UPDATE 语句比 select 语句影响更多的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!