Way 1
if(exists(select name from tempdb..sysobjects where name like'%temptab%' and type='U'))
Way 2
if
Way 3
IF OBJECT_ID('tempdb..#') IS NOT NULL
OBJECT_ID此函数返回数据库对象标识号
判断数据库里有没有存在PerPersonData这样一张表
if exists (select * from sysobjects where objectproperty(object_id('PerPersonData'),'istable') = 1)
OBJECTPROPERTY:返回当前数据库中对象的有关信息。1表“真”。同样可以写成OBJECTPROPERTY(id, isUserTable) = 1
if
drop
判断试图是否存在
if
and