Team:
I am almost there.... Help get the fourth column
The query gives the names of the tables that have foreign keys, name of the field that holds the foreign key, which table it references and then
I need the help to find which colun is it pointing at ... You know what I mean 🙂
😀
Select object_name(fk.parent_object_Id) this_table_has_it, c.name this_is_the_column,
object_name(fk.referenced_object_Id) as references_this_table
FROM sys.foreign_keys fk
inner join sysconstraints o
on fk.object_id = o.constid
inner join sys.columns c on ( ( c.object_id = o.id) and (c.column_id = o.colid) ):-D