http://stackoverflow.com/questions/159038/how-can-foreign-key-constraints-be-temporarily-disabled-using-t-sql
If you want to disable all constraints in the database just run this code:
To switch them back on, run: (the print is optional of course and it is just listing the tables)
I find it useful when populating data from one database to another. It is much better approach than dropping constraints. As you mentioned it comes handy when dropping all the data in the database and repopulating it (say in test environment).
If you are deleting all the data you may find this solution to be helpful.
|
No comments:
Post a Comment