Forum Discussion

McGran's avatar
McGran
Advocate II
2 years ago
Solved

Refresh Failure Due to Temp Database Already Existing

Hi there,   I have a report that was written a couple of years ago and has been merrily refreshing away without trouble until the last week or so (earliest failure I can see in refresh history is 2...
  • Anonymous's avatar
    Anonymous
    1 year ago

    We added code to drop the temp table at the start of each source query that we had used temp tables in.  

     

    IF OBJECT_ID(N'tempdb..#tTempTableName') IS NOT NULL
    BEGIN
    DROP TABLE #tTempTableName
    END

     

    Another solution one of my team mates found was to convert their temp tables to ctes.  

     

    This is a work around we implemented but does not adress the core issue.