CREATE TRIGGER AInsertAffter ON A 
FOR INSERT 
AS
 insert into C 
  value(表A.ID,'表A',表A.MoneyAmount)
Go

解决方案 »

  1.   

    回 zjcxc(邹建) 老大,是ID都是相同的值。如果表A.MoneyAmount发生变化了,那么相应的那条记录
    表C.ID=表A.ID  表C.TableTypeName = '表A' 对应的 表C.MoneyAmount也更新,表C.MoneyAmount=表A.MoneyAmount
    如果表B.MoneyAmount发生变化了,那么相应的那条记录
    表C.ID=表B.ID  表B.TableTypeName = '表B' 对应的 表C.MoneyAmount也更新,表C.MoneyAmount=表B.MoneyAmount
    嗯,就是这样,请邹建老大帮帮忙。
      

  2.   

    create trigger tr_update_表A on 表A
    for update
    as
    update c set C.MoneyAmount=A.MoneyAmount
    from 表C c,inserted A
    where a.id=b.id and C.TableTypeName = '表A' 
    go
    create trigger tr_update_表B on 表B
    for update
    as
    update c set C.MoneyAmount=A.MoneyAmount
    from 表C c,inserted B
    where a.id=b.id and C.TableTypeName = '表B' 
    go
      

  3.   

    --写错别名了.create trigger tr_update_表A on 表A
    for update
    as
    update c set C.MoneyAmount=A.MoneyAmount
    from 表C c,inserted A
    where c.id=A.id and C.TableTypeName = '表A' 
    go
    create trigger tr_update_表B on 表B
    for update
    as
    update c set C.MoneyAmount=A.MoneyAmount
    from 表C c,inserted B
    where c.id=Bb.id and C.TableTypeName = '表B' 
    go