Saturday, 1 October 2011

Find All Constraints of a Database

Execute the below query to find all the constraints in a DB.



SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
           SCHEMA_NAME(schema_id) AS SchemaName,
           OBJECT_NAME(parent_object_id) AS TableName,
           type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT' 

No comments:

Post a Comment