Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fastest way to drop all tables
Message
From
27/02/2008 05:09:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/02/2008 05:00:19
General information
Forum:
Microsoft SQL Server
Category:
Import/Export
Miscellaneous
Thread ID:
01296633
Message ID:
01296763
Views:
7
>>The real problem is not with dropping in a loop but you can't simply drop a table that has objects depend on it. First you need to drop constraints and such and do dropping in an order, be carefull.
>
>This is a brand new database. It doesn't have any constraint. Also, as I mentioned in the first reply once you provided that code, the error is that it cannot execute it. So, it's either I didn't understand the proper syntax on how to use it or either it's not supported on my version. I have SQL Server 2005.

Oh then (I read it can't find such a procedure-it's a system sp and exists with all databases in SQL2005). Try in Management studio:
use myDatabaseName
go

sp_MSForEachTable 'select * from ? where 1=2'
In your case it would be just as Borislav showed:
sp_MSForEachTable 'Drop Table ?'
? is a placeholder for tablename that is fed into procedure foreach call.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform