if exists table in sql code example
Example 1: sql drop table if exists
DROP TABLE IF EXISTS dbo.Customers
Example 2: t-sql test if table exists
IF (EXISTS (SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'TheSchema'
AND TABLE_NAME = 'TheTable'))
BEGIN
--Do Stuff
END
Example 3: sql drop table if exists
IF OBJECT_ID('dbo.Scores', 'U') IS NOT NULL
DROP TABLE dbo.Scores;