sql2005 表设计中其中一个字段为getdate(),插入数据没有问题,但是在更新插入的数据时不能更新,想实现的效果是,更新也此字段也能取到当前的日期。
请各位指教。

解决方案 »

  1.   

    getdate() 默认值的话更新时是不会起作用的。 写个触发器吧! 更新的时候也顺便更新时间字段。
      

  2.   


    create trigger getdate on tb
    for update
    as
    update tb 
    set time=getdate() 
    where id=(select id from deleted)
      

  3.   

    在定义字段时 加上 default getdate(),insert,update时就不要添加这个字段,即可
      

  4.   

    update 不可以,除非指定字段。
    或者触发器 ,不过感觉没必要弄触发器吧,这不找费事呢吗