Created
November 1, 2020 12:31
-
-
Save ssougnez/43ee3da8efb76db5a4de2d9bced53fcd 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
DECLARE @sql NVARCHAR(MAX); | |
SET @sql = N''; | |
SELECT @sql = @sql + N' | |
ALTER TABLE ' + QUOTENAME(s.name) + N'.' | |
+ QUOTENAME(t.name) + N' DROP CONSTRAINT ' | |
+ QUOTENAME(c.name) + ';' | |
FROM sys.objects AS c | |
INNER JOIN sys.tables AS t | |
ON c.parent_object_id = t.[object_id] | |
INNER JOIN sys.schemas AS s | |
ON t.[schema_id] = s.[schema_id] | |
WHERE c.[type] IN ('D','C','F','PK','UQ', 'IX') | |
ORDER BY c.[type]; | |
EXEC sys.sp_executesql @sql; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment