1 判断数据库是否存在Sql代码 if exists (select * from sys.databases where name = ’数据库名’)    drop database [数据库名]  if exists (select * from sys.databases where name = ’数据库名’)  drop database [数据库名]2 判断表是否存在Sql代码 if exists (select * from sysobjects where id = objec…
1 判断数据库是否存在 if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] 2 判断表是否存在 ) ) drop table [表名] 3 判断存储过程是否存在 ) ) drop procedure [存储过程名] 4 判断临时…
SQL SERVER 判断是否存在数据库.表.列.视图 --1. 判断数据库是否存在 IF EXISTS (SELECT * FROM SYS.DATABASES WHERE NAME = '数据库名') DROP DATABASE [数据库名] --2. 判断表是否存在 ) PRINT '存在' ELSE PRINT '不存在' --3. 判断存储过程是否存在 ) PRINT '存在' ELSE PRINT '不存在' --4. 判断临时表是否存在 IF OBJECT_ID('TEMPDB..…
1 判断数据库是否存在if exists (select * from sys.databases where name = '数据库名')    drop database [数据库名] 2 判断表是否存在if exists (select * from sysobjects where id = object_id(N'[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)    drop table [表名] 3 判断存储过程是否存在if ex…
1 判断数据库是否存在 if exists (select * from sys.databases where name = '数据库名') drop database [数据库名] 2 判断表是否存在 if exists (select * from sysobjects where id = object_id(N'[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [表名] 3 判断存储过程是否存在 if exist…
--判断数据库是否存在 if exists (select * from sys.databases where name = '数据库名') drop database [数据库名] --判断表是否存在 ) drop table [表名] --判断存储过程是否存在 ) drop procedure [存储过程名] --判断函数是否存在 IF OBJECT_ID (N'函数名') IS NOT NULL DROP FUNCTION dnt_split --判断数据库是否开启了全文搜索 selec…
发布:thebaby   来源:脚本学堂     [大 中 小] 本文详细介绍了,在sql server中判断数据库或表是否存在的方法,有理论有实例,有需要的朋友可以参考下,一定有帮助的.原文地址:http://www.jbxue.com/db/13356.html 本节内容: Sql Server 判断表或数据库是否存在 在SQL Server中判断数据库是否存在,可以这样: 复制代码代码示例: select * From master.dbo.sysdatabases where name=…
-- SQL SERVER 判断是否存在某个触发器.储存过程 -- 判断储存过程,如果存在则删除IF (EXISTS(SELECT * FROM sysobjects WHERE name='procedurename' AND type='P')) DROP PROCEDURE procedurename -- 判断触发器,如果存在则删除IF (EXISTS(SELECT * FROM sysobjects WHERE id=object_id(N'[dbo].[triggername]')…
使用场景 可以反复的执行相同脚本 方式1:查询sysobjects表 if EXISTS (SELECT * from sysobjects WHERE name='test_table') DROP TABLE test_table create table test_table( id varchar(20), name nvarchar(20) ) 方式2:使用object_id函数 语法 OBJECT_ID ( '[ database_name . [ schema_name ] . |…
前期准备: use studioA;           go create table T(X int,Y int); insert into T(X,Y) values(1,1),(2,2);           go ------------------------------------- use StudioB;           go create procedure proc_for_B           as           begin                 s…