Why are temporary tables not removed from tempdb in SQL Server?

前端 未结 4 536
遥遥无期
遥遥无期 2021-01-20 20:09

I have created one stored procedure with 7 temporary tables and each temp table is dropped at the end of their own work.

I am calling the SP from one web service and

4条回答
  •  不思量自难忘°
    2021-01-20 21:05

    IF object_id('tempdb..#TableName') IS NOT NULL DROP TABLE #TableName
    

    I think this will not work as we know sql server store temp table name with adding some extra character. if exists(select 1 from tempdb.sys.tables where name like '#TableName%') DROP TABLE #TableName

提交回复
热议问题