1 alter table table1 ALTER COLUMN abc decimal(9,2) null
2 select count(id) into :ll_bz from dbo.sysobjects where name = 'fyt_tj_wcettjb';
if ll_bz = 0 then
ls_alter='CREATE TABLE dbo.fyt_tj_wcettjb (tjjd varchar(8) NOT NULL,tjdwbh varchar (20) NOT NULL ,'+&
'tjdwmc varchar (30),jb varchar (1)NOT NULL,xys numeric(8, 0),yis numeric(8, 0) DEFAULT (0),'+&
'ers numeric(8, 0)DEFAULT (0),sans numeric(8, 0) DEFAULT (0),sis numeric(8, 0) DEFAULT (0),'+&
'wus numeric(8, 0) DEFAULT (0),lius numeric(8, 0) DEFAULT (0),qis numeric(8, 0) DEFAULT (0),'+&
'wzmy numeric(8, 0) DEFAULT (0),tjnf varchar (4) NOT NULL)'
execute immediate :ls_alter;
if sqlca.sqlcode <> 0 then
messagebox('创建表失败fyt_tj_wcettjb',sqlca.sqlerrtext)
else
commit;
end if
end if
3 select count(name)into :ll_bz from syscolumns where id in (select id from sysobjects where name = '表名')
and name = '字段名';
if ll_bz = 0 then
ls_alter = "alter table 表名 add 字段名 varchar(1)"
execute immediate :ls_alter;
if sqlca.sqlcode <> 0 then
messagebox('增加字段失败flag1',sqlca.sqlerrtext)
else
commit;
end if
else
ls_alter = "alter table 表名 DROP 字段名 "
execute immediate :ls_alter;
if sqlca.sqlcode <> 0 then
messagebox('增加字段失败flag1',sqlca.sqlerrtext)
else
commit;
end if