create trigger trg1 
on [table]
for update
as
begin
    --取的更新后的记录
    select * from inserted
    
    --判断是否更新
    if update(name)
        select name from inserted
    ......
end
go

解决方案 »

  1.   

    那么你建立一个表Test_2好了,用来记录更新的数据。
    CREATE TRIGGER t_insert
    ON 你自己的表
    FOR INSERT
    AS 
      set xact_abort on
       begin tran
        insert Test_2 select * from Inserted
       commit tran
    go
      

  2.   

    libin_ftsafe(子陌红尘)兄台,按你的方式我还没有取出表中的一个更新的那一个name和IID出来。能不能帮忙再想想。谢谢。
    samfeng_2003(风云) 兄台,我也想按你的那一种方式。做但是DataBase中那么多的表。我不要在那么多的表中*2。其实我只是想当表插入、更新、删除,用触发器得到数据,拼成原来的动作,放到另一个表中去.那一个表只有两个字段.
    如:
    ID     数据
    1      insert table1 values('1','2')
    2      Update table2 set name='1' where iid=1
    3      delete table5 where iid='4'
      

  3.   

    inserted是一个伪表,ID和Name都在里面的你要的到动作的话就要分别建立Insert,Update 和 Delete触发器,吧Name和Id还有操作类型都放到那个表里表的字段就设成如下id   name  OptType
    -------------------
    2    'xxx' 'Update'
    4    'yyy' 'insert'
    6    'ttt' 'delete'
      

  4.   

    有了这个表,就相当于有了原来的动作了三,你自己写一个程序也可以还原成Sql了id   name  OptType
    -------------------
    2    'xxx' 'Update'
    4    'yyy' 'insert'
    6    'ttt' 'delete'