DROP TABLE (Transact-SQL)
Removes one or more tables from a database.
Syntax
DROP TABLE
[ <table_or_view_or_trigger> [ ,...n ] ]
[ ; ]
<table_or_view_or_trigger> ::=
{ <object> | <partition_function> | <partition_scheme> | <user_defined_function> | <view> | <trigger> }
<object> ::=
{ <table> | <sequence_object> | <queue> | <synonym> }
<table> ::=
{ SERVER _LEVEL_OBJECT_ | DATABASE _LEVEL_OBJECT_ }
<server_level_object> ::=
{ LOGIN | ROLE | APPLICATION _ROLE_ }
<database_level_object> ::=
{ USER | SCHEMA | ASSEMBLY | TYPE | ASSEMBLY (<assembly_name>) | TYPE (<type_name>) }
<sequence_object> ::=
{ SEQUENCE }
<queue> ::=
{ QUEUE }
<synonym> ::=
{ SYNONYM }
<partition_function> ::=
{ PARTITION _FUNCTION_ }
<partition_scheme> ::=
{ PARTITION _SCHEME_ }
<user_defined_function> ::=
{ FUNCTION }
<view> ::=
{ VIEW }
<trigger> ::=
{ TRIGGER }
Arguments
This statement supports only one argument:
<table_or_view_or_trigger>
: Specifies the name of the table to be dropped. You can specify multiple table names separated by commas to drop more than one table.
Permissions
To execute DROP TABLE
, the user must be a member of the db_ddladmin
fixed database role or have ALTER
permission on the schema that contains the table.
Examples
Example 1: Dropping a single table
DROP TABLE MySchema.MyTable;
Example 2: Dropping multiple tables
DROP TABLE MySchema.Table1, MySchema.Table2, MySchema.Table3;
Remarks
DROP TABLE
removes the table definition and all data from the database. Any indexes, triggers, constraints, or permissions associated with the table are also removed.
Important: Dropping a table is an irreversible operation. Ensure you have backups before executing this statement.
If you try to drop a table that does not exist, SQL Server will return an error.
Warning: Dropping a table referenced by a foreign key constraint will fail unless the constraint is dropped first.