|
create trigger t_1 on table1 for update
as
select inserted.ID, diff = deleted.amount- inserted.amount into #tmp
from deleted, inserted
where deleted.ID = inserted.ID
update table2
set sum = sum + # tmp.diff
from table2, # tmp
where table2.ID = # tmp.ID
go |
|