同意楼上的意见,SQL SERVER自动管理。

解决方案 »

  1.   

    补充:如果过程中要确认此临时表是否存在有这个方法:
    Create TABLE #t (x INT PRIMARY KEY)
    实际上在tempdb中添加了临时表记录,可通过以下方法查到:
    select * from sysobjects where name like '#t%'
    实际上在tempdb..sysobjects中添加了一条name是#t_________的记录
      

  2.   

    补充:如果过程中要确认此临时表是否存在有这个方法: 
    Create TABLE #t (x INT PRIMARY KEY) 
    实际上在tempdb中添加了临时表记录,可通过以下方法查到: 
    select * from sysobjects where name like '#t_%' 
    实际上在tempdb..sysobjects中添加了一条name是'#t_________'的记录 
    删除:
        Drop Table #t
      

  3.   

    SQL Server supports temporary tables. These are tables whose names start with a number sign (#). If a temporary table is not dropped when the user disconnects, it is dropped automatically by SQL Server. Temporary tables are not stored in the current database, they are instead stored in the system database tempdb. There are two types of temporary tables: Local temporary tables have only one number sign (#) at the start of their name. They are visible only to the connection that created them. 
    Global temporary tables have a double number sign (##) at the start of their name. They are visible to all connections. If they are not dropped explicitly before the connection that created them disconnects, they are dropped as soon as all other tasks stop referencing them. No new tasks can reference a global temporary table after the connection that created it disconnects. The association between a task and a table is always dropped when the current statement completes executing, so global temporary tables are generally dropped soon after the connection that created them disconnects.