Tuesday, February 14, 2012

Delete multiple tables?

SQL Server 2005:
How can I select and delete multiple tables in Management Studio?
Olav"Olav" <x@.y.com> wrote in message
news:%23nm2%23laXGHA.1204@.TK2MSFTNGP04.phx.gbl...
> SQL Server 2005:
> How can I select and delete multiple tables in Management Studio?
> Olav
>
Do you mean DROP the tables or do you mean DELETE the data from tables?
/* Delete ALL data from 3 tables */
DELETE FROM table1 ;
DELETE FROM table2 ;
DELETE FROM table3 ;
/* Drop 3 tables */
DROP TABLE table1 ;
DROP TABLE table2 ;
DROP TABLE table3 ;
Make sure you have a backup before you try these!
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||I did mean from the GUI...
Seems like all the DBAs only work in a command line.
Olav
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:envtF9aXGHA.752@.TK2MSFTNGP02.phx.gbl...
> "Olav" <x@.y.com> wrote in message
> news:%23nm2%23laXGHA.1204@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2005:
>> How can I select and delete multiple tables in Management Studio?
>> Olav
> Do you mean DROP the tables or do you mean DELETE the data from tables?
> /* Delete ALL data from 3 tables */
> DELETE FROM table1 ;
> DELETE FROM table2 ;
> DELETE FROM table3 ;
> /* Drop 3 tables */
> DROP TABLE table1 ;
> DROP TABLE table2 ;
> DROP TABLE table3 ;
> Make sure you have a backup before you try these!
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||"Olav" <x@.y.com> wrote in message
news:uo72tPbXGHA.1204@.TK2MSFTNGP04.phx.gbl...
>I did mean from the GUI...
> Seems like all the DBAs only work in a command line.
>
All the DBAs I know do. I would only recommend the GUI for development - not
on production servers.
If you want to drop multiple tables you can in fact do it from the GUI.
Select the tables node in the Object Explorer, then press F7 for the summary
view. You can now use shift+click to multi-select the tables, then hit
DELETE and click the button to drop them.
I don't think you can delete from more than one table without writing a
script.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||On Wed, 12 Apr 2006 00:04:36 +0200, Olav wrote:
>I did mean from the GUI...
Hi Olav,
Use click, shift-click, and ctrl-click to select the tables to delete;
Right-click one of the selected tables;
Click "delete".
>Seems like all the DBAs only work in a command line.
Indeed. The GUI has some bugs, some strange behaviour, and lacks some of
the finer control possibilities that the command line gives.
Once you've leared to use the SQL Statements, you'll find yourself using
the GUI less and less.
--
Hugo Kornelis, SQL Server MVP

No comments:

Post a Comment