Search notes:

SQL Server: sys.foreign_key_columns

sys.foreign_key_columns lists the columns that participate in a primary foreign key relation.
select
   fkc.constraint_column_id,
   cop.name                    col_fk,
   cor.name                    col_pk,
   fkk.name                    foreign_key_name,
   ret.name                    pk_table,
   pat.name                    fk_table,
   fkc.parent_column_id        col_pk_id,
   fkc.referenced_column_id    col_fk_id
from
   sys.foreign_key_columns  fkc                                                                 join
   sys.foreign_keys         fkk  on fkc.constraint_object_id = fkk.object_id                    join
   sys.objects              pat  on fkc.parent_object_id     = pat.object_id                    join
   sys.objects              ret  on fkc.referenced_object_id = ret.object_id                    join
   sys.columns              cop  on cop.object_id            = pat.object_id              and
                                    cop.column_id            = fkc.parent_column_id             join
   sys.columns              cor  on cor.object_id            = ret.object_id              and
                                    cor.column_id            = fkc.referenced_column_id
where
-- fkk.name = 'tq84_fk'
-- pat.name = 'tq84_f'   -- Child  table anme
   ret.name = 'tq84_p'   -- Parent table name
order by
   fkc.constraint_column_id;

Test data

The following test object might be used to demonstrate the result set of the above select statement.
A table with a primary key constraint.
create table tq84_p (
   col_1    numeric,
   pk_1     numeric,
   col_2    numeric,
   pk_2     numeric,
   col_3    numeric,
   constraint tq84_pk primary key (pk_1, pk_2)
);
And a table with a foreign key constraint:
create table tq84_f (
   col_1    numeric,
   fk_1     numeric,
   col_2    numeric,
   fk_2     numeric,
   col_3    numeric,
   constraint tq84_fk foreign key (fk_2, fk_1) references tq84_p
);

See also

sys.foreign_keys

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740439887, '3.145.21.89', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQL-Server/administration/schemas/sys/objects/views/foreign_key_columns/index(88): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78