Anthony
Anthony

Reputation: 1685

Drop all tables in sql server database using ant script

Can anybody help me with this?

I prefer if I don't have to explicitly list the table names.

Upvotes: 0

Views: 991

Answers (2)

xt_20
xt_20

Reputation: 1446

Saw this before...

exec sp_MSforeachtable "DROP TABLE ? PRINT '? to be dropped' "

Source - http://sqlserver-qa.net/blogs/t-sql/archive/2008/05/20/4266.aspx

Upvotes: 2

wallyk
wallyk

Reputation: 57784

How about dropping the database? DROP DATABASE <database name>

Of course, that's rough on stored procedures, triggers, etc. But if the purpose is to eliminate all the tables in order to recreate them, it makes sense that you'd recreate all the other associated components as well, such as indexes.

Upvotes: 0

Related Questions