码迷,mamicode.com
首页 > 数据库 > 详细

T-SQL常用数据库对象判断语句

时间:2014-06-28 12:39:23      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   数据   表   name   

判断数据库

if exists(select 1 from sys.databases where name=N‘[数据库名]‘)

判断表

if exists (select 1 from dbo.sysobjects where id = object_id(N‘[dbo].[表名]‘) and objectproperty(id, N‘IsTable‘) = 1)

判断字段

if exists(select 1 from syscolumns where id=OBJECT_ID(N‘[dbo].[表名]‘) and name=N‘[字段名]‘))

判断存储过程

if exists (select 1 from dbo.sysobjects where id = object_id(N‘[dbo].[存储过程名]‘) and OBJECTPROPERTY(id, N‘IsProcedure‘) = 1)

 

T-SQL常用数据库对象判断语句,布布扣,bubuko.com

T-SQL常用数据库对象判断语句

标签:style   blog   color   数据   表   name   

原文地址:http://www.cnblogs.com/skykrf/p/3798790.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!