sql2005 如何查询数据库中有哪些临时表?我曾经建过 #tablename 这样的表,现在表名忘了我有没有办法查出我的库中有哪些这样的临时表呢?

解决方案 »

  1.   

    create table #testTable1 

    c1 int 
    ) go 
    if exists(select name from tempdb.dbo.sysobjects where name like '#testTable1%' and type='U')
    Begin 
              --如果表已经存在,执行相应操作 
        SELECT '存在 '
    END 
    ELSE 
    Begin 
              --如果表不存在,执行相应操作 
    SELECT '不存在'
    end  
      

  2.   

    select * from tempdb.sys.tables