请问:
ALTER TABLE abc 
  ALTER COLUMN  dt datetime default(getdate())
在default附近有语法错误建库:
create table abc
(
name varchar(3) not null,
id   int not null,
age  int not null,
dt  datetime not null default(getdate())
)

解决方案 »

  1.   

    alter table table add constraint px default getdate() for dt
      

  2.   

    建库: 
    create   table   abc 

    name   varchar(3)   not   null, 
    id       int   not   null, 
    age     int   not   null, 
    dt     datetime   not   null   default(getdate()) 
    )
    你不已经创建成功了吗?
      

  3.   

    create table T(ID int default (1))--
    select
    [约束名]=a.Name
    [默认值]=b.text 
    from 
    sysobjects  a
    join
    syscomments b on a.ID=b.ID
    where parent_obj=object_id('T') and xtype='D'--
    alter table T drop constraint 约束名
      

  4.   


    create   table   abc 

    name   varchar(3)   not   null, 
    id       int   not   null, 
    age     int   not   null, 
    dt     datetime   not   null   CONSTRAINT AddDateDflt default(getdate()) 
    )goinsert abc(name,id,age) select 'asd',1,10
    select * from abc
    ALTER   TABLE   abc   drop constraint AddDateDflt
    insert abc(name,id,age,dt) select 'asf',1,10,'2007-12-22'
    select * from abcdrop table abc
    /*
    (所影响的行数为 1 行)name id          age         dt                                                     
    ---- ----------- ----------- ------------------------------------------------------ 
    asd  1           10          2007-12-23 22:31:01.237(所影响的行数为 1 行)
    (所影响的行数为 1 行)name id          age         dt                                                     
    ---- ----------- ----------- ------------------------------------------------------ 
    asd  1           10          2007-12-23 22:31:01.237
    asf  1           10          2007-12-22 00:00:00.000(所影响的行数为 2 行)
    */
      

  5.   

    问题是我创建时没有约束名,所以没法drop
      

  6.   

    select
        [约束名]=a.Name,
        [默认值]=b.text 
    from 
        sysobjects  a
    join
        syscomments b on a.ID=b.ID
    where parent_obj=object_id('abc') and xtype='D'