日期:2014-05-18  浏览次数:20431 次

请问这个触发器的语句如何写
大家好!
  我现在有两张表.A表,字段有A001,A002,A003,B表,字段有B001,B002,B003.
   两表通过A001=B001,A002=B002相关联.
   现在,我想在B表新增一条记录,B001,B002,B003,能够能过A001=B001,A002=B002这个关联,新增这个记录时自动的将A003赋值给B003.

------解决方案--------------------
create trigger trg_Insert on tableB
for insert
as
update a set A003 = i.B003 from tableA as a inner join inserted as i
on a.A001 = i.B001 and a.A002 = i.B002
GO