日期:2014-05-18 浏览次数:20647 次
--insert update分开吧,不然还要加些判断的 create trigger A_INS on A for insert,update as if update(F2) update t set t.B2=i.F2 from [DB2].[dbo].[B] t,inserted i where i.ID=t.ID; insert into [DB2].[dbo].[B](B2,ID) select F2,ID from inserted A where not exists (select 1 from [DB2].[dbo].[B] t where t.ID=A.ID and t.F2=B.F2); go