Delete all tables in sql database
Recently I encountered a bizarre request, I had to delete all the tables from an Sql database.
The reason is even more bizarre. The client had a system auto creating them without making sure if they exist first. Ao, I had to write some code to first delete all the tables.
I thought maybe other people like me may encounter the same issue, so I wrote some code for it.
The code can either print out the Drop statements for each table or execute it.
Tested on sql server 2005Submit to Hacker News
[NOTE] This post has been imported to Hugo from a Wordpress blog. It may be broken, missing images, code snippets or other information.
[NOTE] updated May 25, 2009. It's 3535 days old . This article may have outdated content.