How to get List of Enabled / Disabled Check Constraints in SQL Server Database - SQL Server / TSQL Tutorial Part 86

Scenario:

You are working as SQL Server Developer and you are asked to provide list of all Check Constraint with status if enabled or disabled.

Solution:

The below query can be used to get the list of all Check Constraints from a database with status if they are enabled or disabled in SQL Server Database.

--Get List of Enabled / Disabled Check Constraints
SELECT DB_Name() AS DBName
    ,Schema_Name(Schema_id) AS TableSchema
    ,Object_name(parent_object_id) AS TableName
    ,DEFINITION
    ,CASE 
        WHEN is_disabled = 0
            THEN 'NO'
        ELSE 'YES'
        END AS IsDisabled
FROM sys.check_constraints




How to get list of Enabled or Disabled Check Constraints in SQL Server Database




Video Demo : How to get List of Enabled / Disabled Check Constraints in SQL Server