Quick Reminder: How to Disable and Enable All Foreign Key Constraints in Database
This is one of those things I don't do that often (it just doesn't seem like a good idea) so I always have to look it up.
To disable all your constraints, use the following:
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
To endable all constraints, use the following:
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
To disable all your constraints, use the following:
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
To endable all constraints, use the following:
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Comments
Post a Comment