加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-12 15:25:39 所属栏目:MsSql教程 来源:网络整理
导读:判断数据库是否存在 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

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

0 0 (请您对文章做出评价)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读