Technical FAQs

Ask a Question

How to obtain a list of all constraints in a database

Issue
Getting a list of all constraints set in a database.

Product Line
Power Monitoring Expert (any version)

Environment
SQL Server Management Studio (SSMS)

Cause
How to obtain the constraints that are set in a database.  Constraints define the way the Database Engine automatically enforces the integrity of a database by defining rules regarding the values allowed in columns; constraings are the standard mechanism for enforcing integrity.

Resolution
The following query returns all constraints (CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY); it can be run against any database:

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

For detailed information about constraint types click here.
 
Was this helpful?
What can we do to improve the information ?