The DROP TABLE command remove the table definitions and all data, indexes, triggers, constraints and related permissions.
Before you drop a table, you should check if there are any object (views, stored procedures, other tables) that reference the table.
You cannot drop a table referenced by another table by FOREIGN KEY. You must first drop the FOREIGN KEY referencing it.
You can drop a table referenced by a view or stored procedure, but after dropping the table, the view or stored procedure is no longer usable.
The Syntax
DROP TABLE [ IF EXISTS ] [ database_name . [ schema_name ] . | schema_name . ]
table_name [ ,...n ] [ ; ]
IF EXISTS
- Drop the table only if existsdatabase_name
- Specify the name of the database where the table is containedschema_name
- Specify the name of the schema where the table is undertable_name
- Specify the name of the table to be droppedExamples
Remove the table with name TABLE_1 from current database and default schema dbo
DROP TABLE Table_1;
Remove the table with TABLE_1 from database HR and default schema dbo
DROP TABLE HR.Table_1;
Remove the table with TABLE_1 from database HR and schema external
DROP TABLE HR.external.TABLE_1;