--测试数据
create table table1(A varchar(4),B int,C int)
insert into table1
select '0011',1,0
union all select '0012',2,1
union all select '0013',3,0
union all select '0014',5,1
go
--处理触发器
create trigger t_update on table1
after update
as
update table1 set b=-b.b
from table1 a join inserted b on a.a=b.a
where b.c=1 and b.b>0
go
--更新测试
update table1 set b=100
--显示测试结果
select * from table1
go
--删除测试环境
drop table table1
/*--测试结果
A B C
---- ----------- -----------
0011 100 0
0012 -100 1
0013 100 0
0014 -100 1
create trigger t_update on table1
after update
as
update table1 set b=-b.b
from table1 a join inserted b on a.a=b.a
where b.c=1
and b.b>0 --如果仅正值改为负值,就要加上此条件
go