sql query to delete all the tables in a database

Solutions on MaxInterview for sql query to delete all the tables in a database by the best coders in the world

showing results for - "sql query to delete all the tables in a database"
Isiah
28 Jun 2017
1BY LOVE
2
3EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
4DECLARE @sql NVARCHAR(max)=''
5
6SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; '
7FROM   INFORMATION_SCHEMA.TABLES
8WHERE  TABLE_TYPE = 'BASE TABLE'
9Exec Sp_executesql @sql
10