Zolf
asked on
Delete all tables
hello there,
how can i delete all the tables from my hosting sql server 2005 database.one way is to right clcik and select delete.but this is tds since i have more then 30 tables.thanks.
cheers
ZOlf
how can i delete all the tables from my hosting sql server 2005 database.one way is to right clcik and select delete.but this is tds since i have more then 30 tables.thanks.
cheers
ZOlf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do you want to DELETE the data, or the complete table definition (DROP) ?
exec sp_msForEachTable 'DELETE FROM ?'
resp:
exec sp_msForEachTable 'DROP TABLE ?'
Hi there:
To drop all tables in a SQL Server 2005 database use :
sp_MSforeachtable command1 [,replacechar] [, command2] [,command3] [,whereand] [,precommand] [,postcommand
Example : exec sp_MSforeachtable "DROP TABLE ? PRINT '? dropped' "
Best regards...
To drop all tables in a SQL Server 2005 database use :
sp_MSforeachtable command1 [,replacechar] [, command2] [,command3] [,whereand] [,precommand] [,postcommand
Example : exec sp_MSforeachtable "DROP TABLE ? PRINT '? dropped' "
Best regards...
There are some simple queries you can use too...
I have a SQL2000 database here and with this I get a list of all my (user) tables.
select name from sysobjects where xtype = 'U'
Then with curser or text editor I basically issue
drop table tablename1
drop table tablename2
etc...
I have a SQL2000 database here and with this I get a list of all my (user) tables.
select name from sysobjects where xtype = 'U'
Then with curser or text editor I basically issue
drop table tablename1
drop table tablename2
etc...
from information_schema