Sql server

drop all foreign key constraints in a database

drop all foreign key constraints in a database Using below code you can esaly remove all foreign-key constraints of tables. SELECT ‘IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N”[dbo].’ + FK +”’) AND parent_object_id = OBJECT_ID(N”[dbo].’ + PT + ”’)) ALTER TABLE ‘ + PT + ‘ NOCHECK CONSTRAINT ‘ + FK +Continue Reading “drop all foreign key constraints in a database”