Home | Feedback | Login

SQL delete table if exists

It is a good practice to check if a table exists before running the delete statment in SQL. Here is an example.

USE [DatabaseNameeeeeeeeeee]
GO 
IF not OBJECT_ID('dbo.TableNameeeeeeeeeee', 'U') IS NULL
DROP TABLE [dbo].[TableNameeeeeeeeeee]; 
GO