博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

检测临时表存在与否

Posted on 2009-10-28 10:47  郭子  阅读(188)  评论(0编辑  收藏  举报

检测临时表:

if exists (select 1 from tempdb..sysobjects where id=object_id('tempdb..#temp_事实表') and xtype='U') 
  Drop Table #temp_事实表

 

检测基础表:

if exists (select 1
            from  sysobjects
           where  id = object_id('t_事实表')
            and   xtype = 'U')