--如果你用sql语句添加字段,可以解决这个问题:--示例 create table tb(a int) insert tb select 1 union all select 2 union all select null go--为现有字段添加默认值约束 alter table tb add constraint DF_tb_a default 0 for a with values go--添加一个具有默认值的字段 alter table tb add b int default 0 with values --加这个选项 go--显示结果 select * from tb go--删除测试 drop table tb/*--测试结果a b ----------- ----------- 1 0 2 0 NULL 0(所影响的行数为 3 行) --*/
create table tb(a int)
insert tb select 1
union all select 2
union all select null
go--为现有字段添加默认值约束
alter table tb add constraint DF_tb_a default 0 for a with values
go--添加一个具有默认值的字段
alter table tb add b int default 0 with values --加这个选项
go--显示结果
select * from tb
go--删除测试
drop table tb/*--测试结果a b
----------- -----------
1 0
2 0
NULL 0(所影响的行数为 3 行)
--*/