表1:id c1 c2
1 a 0
2 a 0
3 b 0
4 c 0
5 a 0
我现在想写一个触发器:当表1里有数据更新(这个更新肯定为单条数据更新的),且这条数据的c1为a,c2从0变为1了类似:create.....if (这条数据的c1=a AND c2=0)
其它操作....关键就是这条件怎么写
1 a 0
2 a 0
3 b 0
4 c 0
5 a 0
我现在想写一个触发器:当表1里有数据更新(这个更新肯定为单条数据更新的),且这条数据的c1为a,c2从0变为1了类似:create.....if (这条数据的c1=a AND c2=0)
其它操作....关键就是这条件怎么写
create trigger tri_name on t1
for update
as
update t1
set c2=1
from inserted i,t1
where i.id=t.id and i.c1='a' and i.c2=0
for update
as
begin
if((select c1 from inserted)='a' and (select c2 from inserted)=0)
update tablename set c2=1
end