Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Is there a way in SQL to check whether a column is a Primary or Foreign key?
Posted

1 solution

Try this.
SELECT constraint_type
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS a, INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE b
WHERE a.table_name='table_name'
AND a.constraint_name=b.constraint_name
AND b.column_name ='column_name';
 
Share this answer
 
Comments
[no name] 25-Apr-11 8:40am    
good answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900