开发者

Drop all tables in sql server database using ant script

开发者 https://www.devze.com 2022-12-29 15:35 出处:网络
Can anybody help开发者_高级运维 me with this? I prefer if I don\'t have to explicitly list the table names.Saw this before...

Can anybody help开发者_高级运维 me with this?

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消