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

T-sql 各种类型存在并删除

时间:2015-06-18 23:57:45      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:

--表

if exists (select * from dbo.sysobjects where id = object_id(N‘[monthly_budget_work]‘) and OBJECTPROPERTY(id, N‘IsUserTable‘) = 1)
drop table [monthly_budget_work]
GO

--函数

if exists (select * from dbo.sysobjects where id = object_id(N‘[dbo].[fn_all_date_in_term]‘) and xtype in (N‘FN‘, N‘IF‘, N‘TF‘))
drop function [dbo].[fn_all_date_in_term]
GO

--View

if exists (select * from dbo.sysobjects where id = object_id(N‘[dbo].[view_loss]‘) and OBJECTPROPERTY(id, N‘IsView‘) = 1)
drop view [dbo].[view_loss]
GO

--Trigger

if exists (select * from dbo.sysobjects where id = object_id(N‘[dbo].[InsertTrigger_postrn]‘) and OBJECTPROPERTY(id, N‘IsTrigger‘) = 1)
drop trigger [dbo].[InsertTrigger_postrn]
GO

--SP

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N‘[dbo].[sp_download_sales_for_hojinkan]‘) AND type in (N‘P‘, N‘PC‘))
DROP PROCEDURE [dbo].[sp_download_sales_for_hojinkan]
GO

--synonyms

IF EXISTS (SELECT * FROM sys.synonyms WHERE name = N‘FEP_kbn_manage‘)
DROP SYNONYM [dbo].[FEP_kbn_manage]
GO

--assemblies

IF EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N‘SqlServerDebug‘)
DROP ASSEMBLY [SqlServerDebug]
GO

T-sql 各种类型存在并删除

标签:

原文地址:http://www.cnblogs.com/puxian/p/4587250.html

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