create table II ( id int, b int, c int, d int, e int, 合计 int ) insert into II select 1,30,40,30,50,150 insert into II select 1,30,40,30,80,180 insert into II select 1,30,40,30,60,150create trigger tr_updateinfo on II for insert,update as update II set b=0,c=0,d=0,e=0 where b+c+d+e<>合计insert into II select 1,30,40,30,70,150select * from II id b c d e 合计 ----------- ----------- ----------- ----------- ----------- ----------- 1 30 40 30 50 150 1 30 40 30 80 180 1 0 0 0 0 150 1 0 0 0 0 150(4 行受影响)
create trigger tr_T on T for insert,update as update t set b=0,c=0,d=0,e=0 from inserted i ,T where i.ID=T.ID and t.b+t.c+t.d+t.e<>t.合计 ok
(
id int,
b int,
c int,
d int,
e int,
合计 int
)
insert into II select 1,30,40,30,50,150
insert into II select 1,30,40,30,80,180
insert into II select 1,30,40,30,60,150create trigger tr_updateinfo on II
for insert,update
as
update II set b=0,c=0,d=0,e=0 where b+c+d+e<>合计insert into II select 1,30,40,30,70,150select * from II
id b c d e 合计
----------- ----------- ----------- ----------- ----------- -----------
1 30 40 30 50 150
1 30 40 30 80 180
1 0 0 0 0 150
1 0 0 0 0 150(4 行受影响)
create trigger tr_T on T
for insert,update
as
update t
set b=0,c=0,d=0,e=0
from inserted i ,T
where i.ID=T.ID and t.b+t.c+t.d+t.e<>t.合计
ok