實體表
Select * from syscolumns           
where id=object_id(@tablename)  
臨時表                       
Select * From  tempdb..syscolumns              
  where id=object_id('tempdb..'+@tablename)

解决方案 »

  1.   

    我创建的是create table #t1(aa int)
      

  2.   

    if(Select count(*) From  tempdb..sysobjects where id=object_id('tempdb..#t1'))>0
        print '#t1临时表已存在'
    else
        print '#t1临时表不存在'
      

  3.   

    if exists(Select * From  tempdb..sysobjects              
      where id=object_id('tempdb..#T1')
    )
    print '存在'
    else
    print '不存在'
      

  4.   

    if exists(select 1 from db..sysobjects where id=object_id('db..tb'))
       print 'yes'
    else
       print 'no'
      

  5.   

    固定表
      Select * from syscolumns  where id=object_id(@tablename)  
    临时表                       
     Select * From  tempdb..syscolumns  where id=object_id('tempdb..'+@tablename)这个已经问过很多次了,建议你最好先查询一下,也许会更快的解决问题。好运
      

  6.   

    SELECT OBJECT_ID('tempdb..#mytemptable')返回為空,就表示沒有
      

  7.   

    if object_id('tempdb..#temptable') is null
    begin
      ......
    end