sam
sam

Reputation: 1304

How to get list of constraints of a table along with their respective column names in SQL Server 2008 R2

I want to list all constraint names with their respective column name for a table. I am using the below mentioned code :

select * 
from sys.objects
where parent_object_id = object_id('qw') --this gives me the constraints lists but does not give me columns in which they are applied.

select * 
from sys.columns
where object_id = object_id('qw') -- this gives me the column list of the table.

My problem is that I am not able to join these two queries to get columns along with their constraints.

Upvotes: 0

Views: 75

Answers (1)

underscore_d
underscore_d

Reputation: 6791

Sounds like you need CONSTRAINT_COLUMN_USAGE.

Upvotes: 1

Related Questions