Tag Archive: sql-server

How to delete or drop all tables from a SQL Server database using just a SQL query.

The following SQL will delete all the tables and their associated information from a database.

USE [database]
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

The only downside to this is that you cannot perform a rollback, so you need to make sure this is what you want to do. Otherwise, that’s all there is to it. Just run this in a New Query Window in SQL Server Management Studio (SSMS) and you’re done.