?
Solved

drop multiple tables with one command

Posted on 2011-09-02
6
Medium Priority
?
315 Views
Last Modified: 2012-05-12
maybe
drop table1,table2,table3

I want to drop 50 tables

is there a right click shortcut
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Accepted Solution

by:
leoahmad earned 400 total points
ID: 36474217
select 'drop table [' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']'

from INFORMATION_SCHEMA.TABLES

where TABLE_NAME like 'YOUR_CRITERIA%'

 

run the output from that query to drop the tables.
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 400 total points
ID: 36474264
I confirm that you cannot have 1 drop statement to drop several tables at once.
the script above could help to generate all the drop statements...
0
 
LVL 58

Assisted Solution

by:HainKurt
HainKurt earned 400 total points
ID: 36474350
is it difficult to write 50 lines, copy paste, maybe excel can help
first column : drop table
second column : your table name
third column: ;

then copy down 1 & 3 column to row 50
fill 50 table name (or copy paste from some other place)
select all copy ansdd paste into a notepad...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 400 total points
ID: 36474691
with that many i'd recommend doing it in a script and double/treble checking...
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 400 total points
ID: 36478158
You should be able to do:
DROP TABLE table1, table2, table3

>>is there a right click shortcut<<
From Object Explorer Details in SSMS you can select them all and then delete them all at once.
0
 

Author Closing Comment

by:rgb192
ID: 36478196
thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question