Using this SQL on SQL Server 2005
SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = @TableName AND COLUMN_NAME=@ColumnName
I get the Primary Keys AND the Foreign Keys.
How can I get only Foreign Keys? How can I see if a Constraint is a Primary or a Foreign Key?
Thanks
I used the following SQL with SQL Server 2005 to get the Constraint Names by Primary Key:
To get the Constraint Name by Foreing Key:
To get the Foreign Key’s Table and Field by Constraint Name:
To get the Primary Key’s Table and Field by Constraint Name: