Solved

drop multiple tables with one command

Posted on 2011-09-02
6
310 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
6 Comments
 
LVL 14

Accepted Solution

by:
leoahmad earned 100 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 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 100 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 51

Assisted Solution

by:HainKurt
HainKurt earned 100 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 100 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 100 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 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