Showing posts with label Does Temp Table Exist. Show all posts
Showing posts with label Does Temp Table Exist. Show all posts

Thursday, November 29, 2012

Check for existing temp table

This code snippet allows you to check whether a temp table current exists.  If so, drop it.  I use this quite frequently when testing code that I'll run numerous times...

-- check to make sure temp tables doesn't exist
IF (OBJECT_ID('tempdb..#Report')   IS NOT NULL)
            drop table #Report