create table 表 (a int)
go
insert 表 values (1)
go
CREATE TRIGGER 名 ON 表
FOR UPDATE
AS
select a 更新前被删除的数据 from deleted
select a 更新后被插入的数据 from inserted
go
------------测试:
update 表 set a=3

解决方案 »

  1.   

    不用触发器,用timestamp型字段。
      

  2.   

    if update (score)
    update a set a.modifydate = getdate()
    from 表 a
    join inserted b on a.主键 = b.主键
      

  3.   

    --你的表中没有主键吗? 有的话可以用:create trigger t_update on 表
    for update
    as
    if update(score)
      update 表 set modifydate=getdate()
    go
      

  4.   

    --你的表中没有主键吗? 有的话可以用:create trigger t_update on 表
    for update
    as
    if update(score)
      update 表 set modifydate=getdate()
      from 表 a join inserted b on a.主键=b.主键
    go
      

  5.   

    create trigger t_update on 表
    for update
    as
    if update(score)
      update 表 set modifydate=getdate()
    go
      

  6.   

    --如果没有主键,就在表中增加一个标识字段id.然后用:
    create trigger t_update on 表
    instead of update
    as
    if update(score)
      update 表 set modifydate=getdate()
      from 表 a join inserted b on a.id=b.id
    go
      

  7.   

    请问各位:你们说的b是指哪张表啊?我现在只有score一张表。b是需要我自己建的吗?如何建?
      

  8.   

    --如果没有主键,就在表中增加一个标识字段id.然后用:
    create trigger t_update on 表
    instead of update
    as
    if update(score)
      update 表 set modifydate=getdate()
      from 表 a join inserted b on a.id=b.id
    go
    --b表就是inserted呀,是触发器自动新建的一个表,用来存放要插入的数据记录的!