how to drop all tables in sql 1

how to drop all tables in sql

USE Databasename

SELECT  'DROP TABLE [' + name + '];'
FROM    sys.tables

Here is what the above code is Doing:
1. It’s getting a list of all the tables in the database.
2. It’s looping through each table and generating a DROP TABLE statement for each table.
3. It’s printing out the DROP TABLE statement.

Similar Posts