The DROP TABLE IF EXISTS SQL statement enables a check to see that the table exists prior to attempting the dropping (deletion) of the table. If the table does not exists then the DROP TABLE statement is not executed so no error occurs.
The DROP TABLE IF EXISTS SQL statement explained with …
DROP IF EXISTS Table Or Other Objects In SQL Server | My …
DROP IF EXISTS Table Or Other Objects In SQL Server | My …
DROP IF EXISTS Table Or Other Objects In SQL Server | My …
You can use sys.tables since 2005 to simplify this: if exists (select * from sys.tables where name = ‘Scores’) drop table Scores Michael Parker Sep 1 ’15 at 12:47 Add a comment | 26, The SQL Drop Table command will run successfully if SQL database table exists on that SQL Server database. Contrarily if the sql table does not exist in SQL Server database, then sql DROP TABLE command will cause sql engine to throw the following error.
8/30/2012 · To determine if a table exists , its best to go against the sys.objects view by querying the object_id using the fully qualified name of the table . The additional type field in the where clause ensures that the table that is about to be dropped is a User table and not a system table .