Created
August 30, 2021 08:19
-
-
Save RickyLin/74ba549de98c3759fa552fdd856f58a7 to your computer and use it in GitHub Desktop.
Get default constraint name of a column
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
SELECT T.name AS TableName, A.name AS ColumnName, d.name AS ConstraintName | |
FROM sys.default_constraints D | |
INNER JOIN sys.all_columns A ON A.default_object_id = D.object_id | |
INNER JOIN sys.tables T ON T.object_id = A.object_id | |
WHERE T.name = @TableName AND A.name = @ColumnName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment