Skip to content

Instantly share code, notes, and snippets.

@nkigen
Created May 18, 2018 15:17
Show Gist options
  • Save nkigen/b562a834194012d68c152ce17b96a60f to your computer and use it in GitHub Desktop.
Save nkigen/b562a834194012d68c152ce17b96a60f to your computer and use it in GitHub Desktop.
DECLARE @SQL NVARCHAR(MAX) = N'';
SELECT @SQL += N'
ALTER TABLE ' + OBJECT_NAME(PARENT_OBJECT_ID) + ' DROP CONSTRAINT ' + OBJECT_NAME(OBJECT_ID) + ';'
FROM SYS.OBJECTS
WHERE TYPE_DESC LIKE '%CONSTRAINT' AND OBJECT_NAME(PARENT_OBJECT_ID) = 'Your_TABLE';
PRINT @SQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment