SQL Query contraints of a database
Another useful query I was in need of, and found, yesterday. This one is care of Pinal Dave (who writes a very useful blog, which has helped me before), though I added the "Order By" line. This query lists all the constraints of a database. Replace AdventureWorks with your DB name.
USE AdventureWorks; GO 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’ ORDER BY NameofConstraint GO