1.字段是否存在
代码如下 | 复制代码 |
if((select count(*) from syscolumns where name = '字段名' and id=(select id from sysobjects where name='表名'))=0) end |
2.表是否存在
代码如下 | 复制代码 |
if exists (select * from sysobjects where id = OBJECT_ID('表名') and OBJECTPROPERTY(id, 'IsUserTable') = 1) |