if object_id('tempdb..#temp') is not null
  print 'exist'

解决方案 »

  1.   

    if object_id('tempdb..#temp') is not null
    print 'exists!'
    else 
    print 'not exists!'if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fa_accjc]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    用类似的办法,不过,临时表的作用域是局部的。会自动消除。
      

  2.   

    USE TMPDBselect * from sysobjects where type='u'  and name like '#'+@临时表名+'[_]%'
      

  3.   

    USE TMPDBif exists(select * from sysobjects where type='u'  and name like '#'+@临时表名+'[_]%')
     print 'exist'
      

  4.   

    if exists (select * from tempdb..sysobjects where  name like '#你的表名%')