List table check constraints in SQL Server database

Piotr Kononow - Dataedo Team Piotr Kononow 2018-07-02

Table of Contents:

    Query below lists table check constraints.


    select schema_name(t.schema_id) + '.' + t.[name] as [table],
        col.[name] as column_name,
        case when con.is_disabled = 0 
            then 'Active' 
            else 'Disabled' 
            end as [status],
        con.[name] as constraint_name
    from sys.check_constraints con
        left outer join sys.objects t
            on con.parent_object_id = t.object_id
        left outer join sys.all_columns col
            on con.parent_column_id = col.column_id
            and con.parent_object_id = col.object_id
    order by schema_name(t.schema_id) + '.' + t.[name], 


    • table - schema and table name
    • column_id - column table id (unique within table)
    • 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
    • constraint_name - name of the constraint in the database


    • One row represents one check constraint
    • Scope of rows: query returns all check constraints in the database
    • Ordered by table schema and name, table column id

    Sample results

    List of table check constraints in AdventureWorks database.

    There are no comments. Click here to write the first comment.

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy.