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

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

时间:2014-09-18 22:02:44      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   数据   div   sp   cti   log   

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

 

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

标签:style   blog   color   io   数据   div   sp   cti   log   

原文地址:http://www.cnblogs.com/xyyt/p/3980123.html

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