IF Object_ID('tempdb..#Tablename') IS NOT NULL DROP TABLE #Tablename Select * into #Tablename FROM SampleTable