I already have the following query:
SELECT OBJECT_NAME(aFKC.Parent_Object_ID) AS Parent_Table , COL_NAME(aFKC.Parent_Object_ID, aFKC.Parent_Column_ID) AS Parent_Column , OBJECT_NAME(aFKC.Referenced_Object_ID) AS Child_Table , COL_NAME(aFKC.Referenced_Object_ID, aFKC.Referenced_Column_ID) AS Child_Column , OBJECT_Name(aFKC.Constraint_Object_ID) AS Foreign_Key_Name FROM SYS.Foreign_Key_Columns aFKC --SYS.SysForeignKeys
I would like to add two more fields: Parent_Type and Child_Type
Both fields will return either "PK" or "F" basing on the table name and field name.
I know to achieve this, I will have to use:
I haven't been able to join it properly.