This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a T-SQL script to find a list of all CHECK Constraints of SQL Server Database.
Using CHECK Constraints, we are applying business validations or column level validations. Few DBAs also called CHECK Constraint means hidden validation or rule.
When you are working with your transaction system, you may surprise many times because of CHECK constraints.
Periodically, a DBA should prepare the report on defined CHECK Constraints which makes sure about data validation and further implementation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
SELECT S.name + '.' + CC.name AS CheckContraintName ,O.name AS ParentObject ,O.type_desc AS ParentType ,ISNULL(C.name, N'') AS ColumnName ,CC.definition AS ContraintDefinition ,CC.is_disabled AS IsDisabled FROM sys.check_constraints AS CC INNER JOIN sys.schemas AS S ON CC.schema_id = S.schema_id INNER JOIN sys.objects AS O ON CC.parent_object_id = O.object_id LEFT JOIN sys.columns AS C ON CC.parent_object_id = C.object_id AND CC.parent_column_id = C.column_id ORDER BY ParentObject ,ColumnName |
Leave a Reply