DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Listing Default Constraints

08.31.2009
| 3207 views |
  • submit to reddit
        Sql Server 2005 - Retrieve Default Constraint Names

SELECT OBJECT_NAME(PARENT_OBJECT_ID) tableName, COL_NAME (PARENT_OBJECT_ID, PARENT_COLUMN_ID) columnName, NAME DEFAULT_CONSTRAINT_NAME
FROM SYS.DEFAULT_CONSTRAINTS
WHERE OBJECT_NAME(PARENT_OBJECT_ID) = '{table}'
and COL_NAME (PARENT_OBJECT_ID, PARENT_COLUMN_ID) = '{column}'