-- First remove all foreign key constraints between tables
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
-- Execute below query to drop tables from database
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"
In the code snippet, we first remove all the foreign key constraints binding from the tables and then remove all tables by executing the sp_MSforeachtable store procedure.
0 Comments