Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to delete multiple tables???

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2012-05-28 : 03:34:46
Hi,

In my DB there some tables that I would like to delete. Is there a way to do it NOT one by one?

Best Regards.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-28 : 04:15:01
you can use loop with dynamic SQL etc but no matter what it is still DELETE one at a time.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

prett
Posting Yak Master

212 Posts

Posted - 2012-05-28 : 06:08:45
Is there any relationship between the tables?

If no then you can use DROP TABLE statement!! Lets assume that you have five tables named table1, table2, table3, table4, table5 & you want to drop all these five, you can do it in a single DROP statement
DROP table table1, table2, table3, table4, table5

In this statement, you can also use some other arguments like database_name, schema_name etc.

For more information about it check this link:
http://msdn.microsoft.com/en-us/library/ms173790.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-28 : 17:07:07
quote:
Originally posted by raysefo

Hi,

In my DB there some tables that I would like to delete. Is there a way to do it NOT one by one?

Best Regards.


you can generate the delete scripts using catalog view. then you can either manually copy them onto a new window and execute or use dynamic sql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

granuharmot
Starting Member

31 Posts

Posted - 2014-09-23 : 05:16:27
unspammed
Go to Top of Page
   

- Advertisement -