Last active
June 1, 2020 09:58
-
-
Save alantsai/f551d0f445e616647ff5bca558d2e4ba to your computer and use it in GitHub Desktop.
[disable sql constraints (foregin key)] how to disable all sql contraints or goregin key - use for import data #sql
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 | |
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