if Exists(select name from sysobjects where name='addOneArticle' and type='P') drop procedure addOneArticle
--判断是否存在addOneArticle这个存储过程
if exists(select * from dbo.sysobjects where id = object_id(N'[dbo].[countAr]') and OBJECTPROPERTY(id, N'IsTrigger') = 1) drop trigger countAr
--判断是否存在countAr这个触发器
IF EXISTS (SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME = N'<view_name, sysname, view_test>')
DROP VIEW <view_name, sysname, view_test>
--注意一定要加上N'这个不然的话判断不出来
eg:
if exists(
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
where TABLE_NAME = N'v_operation_reason_and_record'
)
drop view v_operation_reason_and_record
来自:http://hi.baidu.com/aaxh/blog/item/b0b361d9fd65332f10df9b78.html