判断数据库是否存在
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 ='全文目录名称'
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 ='全文目录名称'
本文深入探讨了SQL数据库中表、存储过程和函数的判断方法,包括如何判断数据库、表、存储过程和函数的存在性,以及如何使用SQL查询来实现这些判断。同时,文章还介绍了如何检查数据库是否启用了全文搜索和查看全文目录的存在状态。

被折叠的 条评论
为什么被折叠?



