How to drop multiple SQL Server Objects using single DROP statement

It is possible to drop multiple SQL Server objects of the same type (for example databases, tables, views, stored procedures...), using single DROP statement.

To test this we will create 5 new tables:

CREATE TABLE Table1([Column1] [int])
CREATE TABLE Table2([Column1] [int])
CREATE TABLE Table3([Column1] [int])
CREATE TABLE Table4([Column1] [int])
CREATE TABLE Table5([Column1] [int])

To drop the tables, we can use one DROP statement for each table:

DROP TABLE Table1
DROP TABLE Table2
DROP TABLE Table3
DROP TABLE Table4
DROP TABLE Table5

Or we can drop the tables using single DROP statement:

DROP TABLE Table1, Table2, Table3, Table4, Table5

drop_multiple_tables

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">