在一个表中增加或删除字段
1. 先查此表A
//select * from 表A
select * from pay_Formula_Cur
2. 增添字段 如果不需要非空验证 直接添加就可以
/*
alter table 表A add
[字段1] [字段1类型],
[字段2] [字段2类型],
…
*/
alter table pay_Formula_Cur add
[SolutionCode] [nvarchar](100),
[IsSum] [bit]
3. 增添字段 (如果事非空-需要给其设置默认值 )
alter table 表A add 字段名new 字段类型 not null default ‘默认值’
//示列如下
alter table pay_Formula_Cur add SolutionCode nvarchar(200) not null default 'MonthlyPay'
alter table pay_Formula_Cur add isSum bit not null default 1;
4. 删除字段
Alter table 表名 drop column 字段名 --删除数据库表中的字段
Alter table pay_Formula_Cur drop column SolutionCode,IsSum
5. 先查出要删除的字段SQL
select 'alter table '+a.name+' drop column '+b.name from sysobjects a
inner join syscolumns b on a.id=b.id
where a.xtype='U' and b.name='字段名'
如有更好方式请留言多多交流,谢谢