I want to ensure if a temporary table exists in my database or not.
I tried to use OBJECT_ID() function but it seems that I can\'t use it with temporary
OBJECT_ID()
From SQL Server Codebook
How do you check if a temp table exists? You can use IF OBJECT_ID('tempdb..#temp') IS NOT NULL
--Check if it exists IF OBJECT_ID('tempdb..#temp') IS NOT NULL BEGIN PRINT '#temp exists!' END ELSE BEGIN PRINT '#temp does not exist!' END