1: -- determines whether the specified database exists. If yes, the database is deleted.
2:If Exists(SelectNameFromMaster.. sysdatabasesWhereNameIn('Db _ name'))
3:Drop DatabaseDb_name
4:Go
5:
6:-- Determines whether the specified stored procedure exists and deletes it if it exists.
7:If Exists(Select*FromSysobjectsWhereObjectproperty (object_id ('Proc _ name'),'Isprocedure') = 1)
8:Drop ProcedureProc_name
9:Go
10:
11:-- Determines whether the specified table exists. If yes, the table is deleted.
12:If Exists(Select*FromSysobjectsWhereObjectproperty (object_id ('Table _ name'),'Istable') = 1)
13:Drop TableTable_name
14:Go
15:
16:-- Determines whether the specified custom function exists. If yes, delete it.
17:If Exists(Select*FromSysobjectsWhereObjectproperty (object_id ('Dbo. func_name'),'Isansinullson') = 1)
18:Drop FunctionDBO. func_name
19:Go
20:
21:-- Determines whether the specified temporary table exists and deletes it if it exists.
22:If Exists(Select*FromTempdb .. sysobjectsWhereNameLike '# Table_name %')
23:Drop Table# Table_name
24:Go
25: