- 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 OBJECT_ID('临时表') IS NOT NULL
- BEGIN
- PRINT '存在'
- END
- ELSE
- BEGIN
- PRINT '不存在'
- END
-
- IF EXISTS (
- SELECT *
- FROM dbo.sysobjects
- WHERE id = OBJECT_ID(N'[dbo].[视图名]')
- AND OBJECTPROPERTY(id, N'IsView') = 1
- )
- DROP VIEW [dbo].[视图名]
-
- IF EXISTS(
- SELECT *
- FROM syscolumns
- WHERE id = OBJECT_ID('table1')
- AND NAME = 'name'
- )
- BEGIN
- SELECT *
- FROM table1;
- END
-
- IF EXISTS(
- SELECT *
- FROM syscolumns
- WHERE id = OBJECT_ID('table1')
- AND NAME = 'name'
- )
- BEGIN
- SELECT *
- FROM table1;
- ALTER TABLE table1 DROP COLUMN NAME
- END
posted @
2017-03-16 14:10
守夜人1
阅读(
335)
评论()
编辑
收藏
举报