After blogging about how to disable all Foreign Key constraints and the undocumented sp for looping through all tables in a database, I thought about combining the two.
So I’ve now got a much easier way to disable FK constraints in a database.
The script below will loop through each table and disable the FK check.
--Disable FK Checks
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
I’ve got an application that has a SQL CE offline mode where the Foreign Key keyword is not supported when running scripts against it. (At least that’s what I’ve been told by the original developer).
posted @ Monday, August 19, 2013 12:36 PM