ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Sql Server判断数据库、表、存储过程、函数是否存在

Sql Server判断数据库、表、存储过程、函数是否存在

原创 Linux操作系统 作者:talentmsy 时间:2010-05-23 20:22:59 0 删除 编辑

 

 

判断数据库是否存在
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 ='全文目录名称'

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23947808/viewspace-663488/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-05-20

  • 博文量
    31
  • 访问量
    30517