首页 > 数据库技术 > 详细

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

时间:2015-06-18 23:57:28      阅读:440      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!