if   object_id('tempdb..##TEMPTABLE1')   is   not   null   
   drop   table   ##TEMPTABLE1   

  

上面一种不检查类型,##TEMPTABLE1可能是view或procedure的名字,完整的检查如下 

 if   exists   (select   *   from   tempdb.dbo.sysobjects   where   id   =   object_id(N'tempdb..##TEMPTABLE1')   and   type='U')   

  drop   table   ##TEMPTABLE1 

相关文章: