Creat Trigger trg_update ON table1
FOR update AS
update table3
set total=total+(select sum(qty) from table2 b where a.id=b.id ) from table3 a,table2 b
where a.id in (select id from table1)
Creat Trigger trg_update ON table1
FOR update AS
update table3
set total=total+(select sum(qty) from table2 b where a.id=b.id ) from table3 a,table2 b
where a.id in (select id from table1)
create trigger tr_table1_update
on table1
for update
as
if update (ii)
update table3
set total=total+(select sum(qty) from table2 b where a.id1=b.id1 and b.id in (select id from inserted where ii=1)) from table3 a
where id1 in (select id1 from table2 where id in (select id from innserted where ii=1))