When working with SQL data and lots of foreign keys, you may have the need to drop everything. Well I have just the right SQL statement for you. The following statement will drop everything the given database, including the following:
- non-system stored procedures
- foreign key constraints
- primary key constraints
You can execute parts of the script on its own if you only want to drop a certain part.
Drop everything in a MSSQL database
The SQL script must be execute on the database level. Optionally you can add an USE ‘YOUR_DATABASE_NAME’ statement on the top.
I added the option to iterate over all schemas in the selected database and drop everything in every schema including the schema.