Thank this author by sharing:
By Jack Corbett,
This script is fairly self-explanatory. It uses the INFORMATION_SCHEMA views to return all foreign keys within a database including the Parent or Primary Key Table and Column(s) as well as the Child Table and Column(s). This could be adapted to work for any database by creating a stored procedure that accepts an @DbName parameter and adds it to the Views referenced in the From clause to create 3-part naming.
As a member of SQLServerCentral, you get free access to loads of fresh content: thousands
of articles and SQL scripts, a library of free eBooks, a weekly database news roundup,
a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals
that makes it such a success.