日期:2014-05-17 浏览次数:20704 次
declare @finterid int
declare @sum int
……
select sum(A) as @sum from tableA
where finterid=@finterid
……
select @sum = sum(A) from tableA
where finterid=@finterid
create trigger tr_TableA on tableA
for insert,update
as
update t2
set SumA=t1.SumA
from (select finterid,sum(A) as SumA
from tableA where finterid in(select finterid from inserted)
group by finterid) as t1
inner join tableA as t2 on t1.finterid=t2.finterid