SQL Server · 2019-10-21

T-SQL Temp Table Check

What’s better than dropping your temp tables at the end of every script? Checking for their existence at the beginning of the script and dropping them.

IF OBJECT_ID('tempdb..#t') IS NOT NULL DROP TABLE #t;