`
to_zoe_yang
  • 浏览: 139353 次
  • 性别: Icon_minigender_2
  • 来自: 01
社区版块
存档分类
最新评论

判断判断数据库,表是否存在

 
阅读更多
判断数据库是否存在
if exists (select * from sys.databases where name = '数据库名') drop database [数据库名]
判断表是否存在
if exists (select * from sysobjects where id = object_id(N'[表名]') and
判断数据库是否存在
if exists (select * from sys.databases where name = '数据库名')
drop database [数据库名]
判断表是否存在
if exists (select * from sysobjects where id = object_id(N'[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [表名]


判断存储过程是否存在
if exists (select * from sysobjects where id = object_id(N'[存储过程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [存储过程名]


判断函数是否存在
IF OBJECT_ID (N'函数名') IS NOT NULL
DROP FUNCTION dnt_split


判断数据库是否开启了全文搜索
select databaseproperty('数据库名','isfulltextenabled')


判断全文目录是否存在
select * from sysfulltextcatalogs where name ='全文目录名称'
分享到:
评论
2 楼 to_zoe_yang 2011-04-24  
判断表是否存在的另一种方法

use [数据库名]
if object_id('[表名]') IS NOT NULL
PRINT 'exit'
else
PRINT 'not exit'
1 楼 to_zoe_yang 2011-04-24  
使用存储过程对数据表或者表操作前,最好判断其是否存在!

相关推荐

Global site tag (gtag.js) - Google Analytics