Last active
December 26, 2015 08:29
-
-
Save FeniXb3/7122905 to your computer and use it in GitHub Desktop.
Disable and re-enable all constraints on database in T-SQL. Reference - http://stackoverflow.com/a/161410/1816426
This file contains 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 all constraints | |
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" | |
-- enable all constraints - the print is optional | |
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