您的位置:首页 > 数据库

执行SQL脚本语句判断是否已经存在

2011-12-12 09:57 357 查看
1.字段是否存在

if((select count(*) from syscolumns where name = '字段名' and id=(select id from sysobjects where name='表名'))=0)
begin

end

2.表是否存在

if exists (select * from sysobjects where id = OBJECT_ID('表名') and OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE 表名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: