Find all foreign keys constraints in database referencing a certain primary key

foreign-key-relationship, foreign-keys, primary-key, sql, sql-server

Solution

Look at How to find foreign key dependencies in SQL Server?

You can sort on PK_Table and PK_Column to get what you want

Problem

I want to find all foreign keys in my database that reference to a primary key of a certain table. For example, I have a column `A` in table `T` which is the primary key. Now I want to find in which tables column `A` is referenced in a foreign key constraint? One simple way I've considered is to check the database diagram, but this only works if a database is very small. It's not a very good solution for a database that has more than 50 tables. Any alternatives?

Original source

Related problems