sql server检查临时表是否存在

  
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 

posted on 2008-08-14 11:27  聪明的大熊  阅读(3120)  评论(0)    收藏  举报