插入时不指定该字段,默认值才会生效,如果插入NUL结果则就是NULL。

解决方案 »

  1.   

    alter table yourtable add constraint name1 default getdate() for col
      

  2.   

    Try it:create table test(id int identity(1,1),name varchar(20),
    time smalldatetime default(getdate()))insert test values('abc',default)select * from test
      

  3.   

    OH,我犯了个低级错误。我是在SQL的查询分析器插入数据的,所以不会出现默认值。不过,我用smalldatetime的目的就是只希望只有日期数据,那么我该在默认值中怎么设置默认值,使插入记录时自动只插入日期。
      

  4.   

    將默認值設為 left(getdate(),10)
      

  5.   

    无论是使用smalldatetime还是datetime,都不可能只有日期没有时间。