Delete if Yes
-- Determines whether the specified database exists. If yes, the database is deleted.
If exists (select name from master .. sysdatabases where name in (''db _ name ''))
Drop database db_name
Go
-- Determines whether the specified stored procedure exists and deletes it if it exists.
If exists (select * from sysobjects where objectproperty (object_id (''proc _ name''), ''isprocedure '') = 1)
Drop procedure proc_name
Go
-- Determines whether the specified table exists. If yes, the table is deleted.
If exists (select * from sysobjects where objectproperty (object_id (''table _ name''), ''istable'') = 1)
Drop table table_name
Go
-- Determines whether the specified custom function exists. If yes, delete it.
If exists (select * from sysobjects where objectproperty (object_id (''dbo. func_name ''), ''isansinullson'') = 1)
Drop function dbo. func_name
Go
-- Determines whether the specified temporary table exists and deletes it if it exists.
If exists (select * from tempdb .. sysobjects where name like ''# table_name % '')
Drop table # table_name
Go