create trigger tr_表 on 表 for insert,update as if exists(select 1 from inserted where 字段1=1 and 字段2=1 and 字段3=1) begin update 表 set 字段4=1 from 表, inserted i where 表.字段4=0 and i.字段1=1 and i.字段2=1 and i.字段3=1 end
create trigger tr_tablename_update on tablename for update,insert asupdate a set 另外一个=1 from tablename a,inserted i where a.关键字=i.关键字 and a.固定1=1 and a.固定2=1 and a.固定3=1 and a.另外一个=0go
for insert,update
as
if exists(select 1 from inserted where 字段1=1 and 字段2=1 and 字段3=1)
begin
update 表
set 字段4=1
from 表, inserted i
where 表.字段4=0 and i.字段1=1 and i.字段2=1 and i.字段3=1
end
on tablename
for update,insert
asupdate a
set 另外一个=1
from tablename a,inserted i
where a.关键字=i.关键字
and a.固定1=1
and a.固定2=1
and a.固定3=1
and a.另外一个=0go