文章介绍了关于sql判断表名与字段名是否存在语句有需要的同学参考一下。
1.字段是否存在
代码如下 | |
if(( 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) |
Copyright © 2019- oldu.cn 版权所有 浙ICP备2024123271号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务