Tuesday, July 18, 2017

Tables Related by Column

Found a short query that shows how tables in a database are related by column (i.e. they share a column):

SELECT
  A.COLUMN_NAME,
  a.TABLE_NAME,
  b.TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS A
JOIN INFORMATION_SCHEMA.COLUMNS B
  ON A.COLUMN_NAME = B.COLUMN_NAME

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.