备忘SQL—2

 

代码
--查询数据库中是否存在某个表
if exists(select * from sysobjects where name='表名')
--查询数据库中是否存在某个触发器
if exists(select * from sysobjects where name='触发器名' AND type='TR')
--查询数据库中是否存在某个外键
if exists(select * from sysobjects where id=object_id(N'外键名'AND objectProperty(id, N'IsForeignKey')=1)
--查询表中是否存在某一列
if exists(select 1 from syscolumns where id=object_id('表名'and name='列名')

 

 

posted @ 2010-06-13 15:08  战斧神话  阅读(119)  评论(0编辑  收藏  举报