下面为您介绍使用用sql脚本添加删除表里面字段的实例,如果您在这方面遇到了问题,不妨一看,相信会对您有所启迪。
SQL代码
use asm
——–删除字段
if exists (select * from syscolumns where id =object_id(‘tb_log’) and name=‘COLUMN1′)
ALTER TABLE [tb_log ] DROP COLUMN [COLUMN1]
if exists (select * from syscolumns where id =object_id(‘tb_log’) and name=‘COLUMN2′)
ALTER TABLE [tb_log ] DROP COLUMN [COLUMN2]
if exists (select * from syscolumns where id =object_id(‘tb_log’) and name=‘COLUMN3′)
ALTER TABLE [tb_log ] DROP COLUMN [COLUMN3]
if exists (select * from syscolumns where id =object_id(‘tb_log’) and name=‘COLUMN4′)
ALTER TABLE [tb_log ] DROP COLUMN [COLUMN4]
———添加字段
alter table tb_log
add COLUMN5 nvarchar(200),
COLUMN6 int