有表tb如下
tb
(AA int ,
BB char,
CC datetime
)现要在插入AA,BB的时候,取系统当前时间自动插入CC,也就是记录字段插入的时间,求这样的触发器
有劳!!!

解决方案 »

  1.   

    这个问题和我刚才的问题差不多,为什么不用default
    create table tb
    (
    aa int,
    bb char,
    cc dateTime default getdate()
    )
      

  2.   

    --不需要 直接加个默认就可以了 
    alter table tb add constraint DF_K DEFAULT GETDATE() FOR CC 
      

  3.   

    --一定要用触发器 你可以这样
    create trigger on tb 
    after insert
    as
    begin 
    update tb
    set cc=getdate()
    from inserted i
    where i.aa=aa i.bb=bb
    end
    我推荐楼主用默认值