请问:
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())
)
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())
)
create table abc
(
name varchar(3) not null,
id int not null,
age int not null,
dt datetime not null default(getdate())
)
你不已经创建成功了吗?
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 约束名
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 行)
*/
[约束名]=a.Name,
[默认值]=b.text
from
sysobjects a
join
syscomments b on a.ID=b.ID
where parent_obj=object_id('abc') and xtype='D'