sql腳本添加刪除表里面字段的實(shí)例
下面為您介紹使用用sql腳本添加刪除表里面字段的實(shí)例,如果您在這方面遇到了問(wèn)題,不妨一看,相信會(huì)對(duì)您有所啟迪。
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