1, determine whether there is addonearticle this stored procedure
If Exists (select name from sysobjects where name = ' addonearticle ' and type= ' P ')
drop procedure Addonearticle
2, determine whether there is countar this trigger
if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Countar] ') and OBJECTPROPERTY (ID, N ' istrigger ') = 1)
Drop Trigger Countar
3, judge whether there is view_1 this view
IF EXISTS (SELECT table_name from INFORMATION_SCHEMA. Views WHERE table_name = N ' view_1 ')
DROP View View_1
4, judge whether there is user_fun this user function
(Note that there are two types in this type, the ' TF '-table-valued function table-valued functions or the ' FN '-scalar-valued function Scalar-valued functions)
if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ User_fun] and (type = ' FN ' or type = ' TF ')
DROP FUNCTION User_fun
5. Determine if the table ' Tb ' exists
if (Exists (SELECT * from dbo.sysobjects WHERE id = object_id (n ' Tb ') and OBJECTPROPERTY (ID, n ' isusertable ') = 1))
DROP TABLE Tb
6. Determine if the database exists
if exists (SELECT * from master.dbo.sysdatabases where dbid=db_id (' scbjdb '))
Drop Database Scbjdb
Else
print ' No exist scbjdb '
SQL Server 2000/2005 determines whether stored procedures, triggers, views exist, and deletes