日期:2014-05-18 浏览次数:20531 次
create trigger tg_yourname on dbo.A FOR INSERT AS BEGIN insert into B( a1,b1,c1,d1 ) select a,b,c,d from inserted x END
------解决方案--------------------
随手敲的,难免手误:)
CREATE TRIGGER insertAfterINSERT ON tA FOR UPDATE AS IF UPDATE(a) INSERT tB(a1,b1,c1,d1) SELECT a,b,c,d FROM INSERTED
------解决方案--------------------
楼主的意思是说,你在更新a的时候,是有条件控制的吧,
比如说update A set a=b where id=2这样的更新语句,如果没有条件的话,会把所有的a全给修改.
create trigger tr
on A
for update
as
begin
insert into B (a1,b1,c1,d1) select a,b,c,d FROM A where id=2
end