Browse FAQs

How to obtain a list of all constraints in a database

Published date: 25 March 2019

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; constraints are the standard mechanism for enforcing integrity.

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

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

For information about Primary and Foreign Key constraints click here.
For information about Unique and Check constraints click here.
 

Was this helpful?

What can we do to improve the information ?

Can't find what you are looking for?

Reach out to our customer care team to receive information on technical support, assistance for complaints and more.