--判断库是否存在,存在则删除
if exists (select name from master..sysdatabases where name in (‘db_name‘))
drop database db_name
go
--判断存储过程是否存在,存在则删除
if exists (select * from sysobjects where objectproperty(object_id(‘proc_name‘), ‘IsProcedure‘)=1)
drop procedure proc_name
go
--判断表是否存在,存在则删除
if exists (select * from sysobjects where objectproperty(object_id(‘table_name‘),‘istable‘)=1)
drop table table_name
go
--判断自定义函数是否存在,存在则删除
if exists (select * from sysobjects where objectproperty(object_id(‘dbo.func_name‘), ‘isansinullson‘)=1)
drop function dbo.func_name
go
--判断临时表是否存在,存在则删除
if exists (select * from tempdb..sysobjects where name like ‘#table_name%‘)
drop table #table_name
go