Removes one or more tables from a database.
DROP TABLE
[ database_name.schema_name.table_name -- Applies to: SQL Server 2008 and later
| schema_name.table_name
| table_name
]
[ ,...n ]
[ ; ]
DROP TABLE removes the definition of a table and all its data. If any views or stored procedures reference the table, the DROP TABLE statement will fail unless those objects are dropped or modified first.
You can use DROP TABLE to drop multiple tables with a single statement. However, if you try to drop a table that does not exist, an error will be raised.
DROP TABLE requires ALTER permission on the schema that contains the table or db_ddladmin database role membership.
The following example drops the table named ProductVendors.
DROP TABLE ProductVendors;
The following example drops two tables: Products and ProductCategories.
DROP TABLE Products, ProductCategories;
The following example drops the table Sales.Customers in the AdventureWorks database.
DROP TABLE AdventureWorks.Sales.Customers;
If you need to drop tables conditionally, you can use the following pattern:
IF OBJECT_ID('YourSchema.YourTable', 'U') IS NOT NULL
DROP TABLE YourSchema.YourTable;