Created
August 3, 2012 03:05
-
-
Save jdu/3243962 to your computer and use it in GitHub Desktop.
Disable/Enable Foreign Key Constraints for DB migrations [SQL Server]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable | |
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" | |
# Enable | |
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment