IF temp table exists in SQL Server

Wondering how to know if a temp table already exists in the database. Here is a simple command

IF
OBJECT_ID(‘tempdb..#temp’) IS NOT NULL

DROP TABLE #temp


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.