请教:
sql2000中如现在字段a值为b
如何能让b改为c时给另一字段赋为当前时间

解决方案 »

  1.   

    1.你可以直接在update时赋予另一字段当前时间.
    2.也可以在触发器中赋予另一字段当前时间.
      

  2.   

    1.你可以直接在update时赋予另一字段当前时间.
    update tb set a = 'c' , 另一字段 = getdate() where a = 'b' 2.也可以在触发器中赋予另一字段当前时间.
    create trigger my_trig on tb for update
    as
    begin
      update tb set 另一字段 = getdate() 
      from tb , deleted d, inserted i
      where tb.关键字 = d.关键字 and tb.关键字 = i.关键字 and d.a = 'b' and i.a = 'c'
    end
      

  3.   

    同时update两个字段
    或者update一个字段的时候用触发器update另一个字段
      

  4.   


    --直接更新
    update tbl set a=c,另一字段=getdate() where a='b'
    --使用触发器
    create trigger tri_update
    for update
    as
    begin
    if exists(select 1 from detelet)
    and exists(select 1 from inserted)
    begin
    update tbl set 另一字段=getdate() from tbl a
    deleted b, inserted c where a.关键字段= b.关键字段
    and a.关键字段= c.关键字段and a.a = 'b' and c.a = 'c'
    end
    end