Drop/Delete All Tables in a SQL Server Database

When working with complex schemas, there are plenty of situations when you would want to drop/delete all the tables in a SQL Server database. This is pretty easy to do with the sp_msforeachtable stored procedure.  Before executing the scripts bellow, please make sure you are working on the correct database and that your user has the necessary permission to perform the delete/drop operations:

Here is how you can drop all the tables in a SQL Server Database:

EXEC sp_msforeachtable 'DISABLE TRIGGER ALL ON ?'
EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'
EXEC sp_msforeachtable 'DROP TABLE ?'

Here is how you can delete all the records in all the tables in a SQL Server Database:

EXEC sp_msforeachtable 'DISABLE TRIGGER ALL ON ?'
EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'
EXEC sp_msforeachtable 'DELETE FROM ?'