Created
January 22, 2019 13:59
-
-
Save PRElias/2c655b6f33f10180ebbf6ee4dc0c0f4a to your computer and use it in GitHub Desktop.
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
-- Get ALTER TABLE Script for all tables to Enable all constraints for database | |
SELECT distinct 'ALTER TABLE [' + s.name + '].[' + o.name + '] WITH CHECK CHECK CONSTRAINT all' | |
FROM sys.foreign_keys i | |
INNER JOIN sys.objects o ON i.parent_object_id = o.OBJECT_ID | |
INNER JOIN sys.schemas s ON o.schema_id = s.schema_id | |
GO | |
-- Get ALTER TABLE Script for all tables to Disable all constraints for database | |
SELECT distinct 'ALTER TABLE [' + s.name + '].[' + o.name + '] NOCHECK CONSTRAINT all' | |
FROM sys.foreign_keys i | |
INNER JOIN sys.objects o ON i.parent_object_id = o.OBJECT_ID | |
INNER JOIN sys.schemas s ON o.schema_id = s.schema_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment