Skip to content
Loading
Temporary Tables in Temp db
  • Hi
     
     Is it safe to delete temp tables in Temporary tables.
     
    Thanks 
    +3
  • Amit Mohanty

    Muhammad Imran Ansari is right, if you want to drop a temp table use

    1. IF OBJECT_ID('tempdb..#temp0') IS NOT NULL DROP TABLE #temp0 
    +3
  • Muhammad Imran Ansari
    If an application/any other process is already connected to the database you are trying to drop , you may get that error. Try to disconnect from the database first and drop the schema , it should work.
    1. IF OBJECT_ID(N'tempdb..#AO554DDE') IS NOT NULL  
    2. BEGIN  
    3.         DROP TABLE #AO554DDE  
    4. END  
    5. GO  
     
    +4