SELECT
    cast( info.TABLE_SCHEMA as CHAR ) as TABLE_SCHEMA,
    cast( info.TABLE_NAME as CHAR ) as TABLE_NAME,
    cast( info.COLUMN_NAME as CHAR ) as COLUMN_NAME,
    cast( info.REFERENCED_TABLE_SCHEMA as CHAR ) as REFERENCED_TABLE_SCHEMA,
    cast( info.REFERENCED_TABLE_NAME as CHAR ) as REFERENCED_TABLE_NAME,
    cast( info.REFERENCED_COLUMN_NAME as CHAR ) as REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE info
JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS cons
ON cons.CONSTRAINT_NAME = info.CONSTRAINT_NAME AND cons.CONSTRAINT_SCHEMA = info.CONSTRAINT_SCHEMA AND cons.CONSTRAINT_TYPE = 'FOREIGN KEY'

