Created
June 22, 2021 14:12
-
-
Save ZackStone/dcb8c5fd01df4bc23f2a4ecc1d09f2c3 to your computer and use it in GitHub Desktop.
Drop all tables in a SQL Server database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://stackoverflow.com/questions/8439650/how-to-drop-all-tables-in-a-sql-server-database/20994549#20994549 | |
EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all' | |
EXEC sp_msforeachtable 'DROP TABLE ?' | |
-- but second line you might need to execute more then once until you stop getting error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment