The query below lists the check constraints defined in the database, ordered by constraint name.
Check this query to see them organized by table.
select con.[name] as constraint_name, schema_name(t.schema_id) + '.' + t.[name] as [table], col.[name] as column_name, con.[definition], case when con.is_disabled = 0 then 'Active' else 'Disabled' end as [status] from sys.check_constraints as con left outer join sys.objects as t on con.parent_object_id = t.object_id left outer join sys.all_columns as col on con.parent_column_id = col.column_id and con.parent_object_id = col.object_id order by con.name
- constraint_name - name of the constraint in the database
- table - schema and table name for which the constraint is defined
- column_name - name of the column for column-level check constraints, null for table-level check constraints
- definition - SQL expression that defines this check constraint
- status - constraint status
- 'Active' if constraint is active,
- 'Disabled' for disabled constraints
- One row: represents one check constraint
- Scope of rows: the query returns all check constraints in the database
- Ordered by: constraint name
List of check constraints in the AdventureWorksLT database.