Sql判斷數(shù)據(jù)庫、表、存儲過程、函數(shù)是否存在
來源:程序員人生 發(fā)布時間:2014-06-09 21:35:21 閱讀次數(shù):3710次
判斷數(shù)據(jù)庫是否存在
if exists (select * from sys.databases where name = '數(shù)據(jù)庫名')
drop database [數(shù)據(jù)庫名]
判斷表是否存在
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 [存儲過程名]
判斷函數(shù)是否存在
IF OBJECT_ID (N'函數(shù)名') IS NOT NULL
DROP FUNCTION dnt_split
判斷數(shù)據(jù)庫是否開啟了全文搜索
select databaseproperty('數(shù)據(jù)庫名','isfulltextenabled')
判斷全文目錄是否存在
select * from sysfulltextcatalogs where name ='全文目錄名稱'
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈