Browse FAQs

How to obtain a list of all constraints in a database

Published date: 29 June 2020

Getting a list of all constraints set in a database.

Product Line
Power Monitoring Expert

SQL Server Management Studio (SSMS)

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.

*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.*

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


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.