Hi Sheraz Mirza,
This is a Useful script. But a little Correction to the Script. IF there are schema's used in the DB then the Query Gives some issues. If the same name exists in different Schema then its a problem so you should be inner join condition should check for Schema Compare between the two tables.
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC ON CU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME AND CU.TABLE_SCHEMA = TC.CONSTRAINT_SCHEMA
AND TC.CONSTRAINT_TYPE = 'FOREIGN KEY'
AND CU.TABLE_SCHEMA in ('xyz','xyz123','xyz456')
ORDER BY CU.TABLE_SCHEMA, CU.TABLE_NAME
Hope This would would be helpful.
Thanks once again and the query you gave is an informative and good one.