请问大家一个触发器中更新语句的问题
请教大家一个问题,我在触发器要执行下面的操作
update t1 set t1.price=t2.price
from table 1,inserted t2
where t1.ID=t2.SourceID
and t2.SourceType='采购订单'
我需不需要在这个语句前面加一个if条件呢?比如:
if exists(select 1 from inserted where SourceType='采购订单')
begin
update t1 set t1.price=t2.price
from table 1,inserted t2
where t1.ID=t2.SourceID
and t2.SourceType='采购订单'
end
我在所有的触发器的第一行都有加
if @@rowcount=0 return
请问,如果不加if条件,会有可能存在什么隐患么?