结合系统表来判断吧:select * from information_schema.columns where table_schema='库' and table_name ='表' and column_name='字段'
谢谢vinsonshen 结合上面的修改语句在一起怎么写 我这样写不对!! if exists (select * from information_schema.columns where table_name ='meter' and column_name='MAXRONGLIANG') begin alter table meter modify MAXRONGLIANG smallint end
select count(*) into @i from information_schema.columns where table_name ='meter' and column_name='MAXRONGLIANG'; if @i >0 then ... end if;
结合上面的修改语句在一起怎么写
我这样写不对!!
if exists (select * from information_schema.columns where table_name ='meter' and column_name='MAXRONGLIANG')
begin
alter table meter modify MAXRONGLIANG smallint
end
if @i >0 then
...
end if;