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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Drop all tables in database

Author  Topic 

multiplex77
Starting Member

24 Posts

Posted - 2007-01-31 : 22:21:44
Hi everyone,

Can anyone share with me a simple T-SQL command whereby I can drop all the user-defined tables in my database? I've googled all over but just can't seem to find something that fits.

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-31 : 22:36:34
use SSMS, select all the table. Right Click and choose Script Table as DROP TO


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-31 : 23:14:49
If you want to do in via T-SQL, it won't be a 'simple T-SQL' command. Why do you need to drop all tables ?


KH

Go to Top of Page

MohammedU
Posting Yak Master

145 Posts

Posted - 2007-02-01 : 02:00:39
exec sp_msforeachtable 'drop table ?'

MohammedU
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-02-01 : 11:30:39
how about

USE MASTER
DROP DATABASE 'yourdbhere'



[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -