SQL Server - quickly delete all tables

Fri, Oct 12, 2018 One-minute read

With most things in SQL Server it’s tempting to think you can script it. Because most of the time you can.

Recently, I had a requirement to quickly drop everything out of a database (but without actually just dropping the whole database.)

The best option I found, was:

  1. In the database tree view, find the container for the type of objects you want to delete (e.g., tables)
  2. Press F7 to open up the Object Explorer
  3. From here, select all the items you want to delete. Press delete.
  4. This opens up the standard ‘drop item’ dialog, but with all those objects included.
  5. Hit OK

And boom, away it goes. You can repeat this for any database objects by navigating around the Object Explorer. If you wanted to script this, you’d need to (probably) start navigating the master database and get some cursors and whatnot going on.