← back to the blog

T-SQL To search table name by column name

Posted in SQL by dake

SQL example to search table name in case if you only know the column name

SELECT      t.name AS 'TableName', c.name  AS 'ColumnName'
FROM        sys.columns c
JOIN        sys.tables  t   ON c.object_id = t.object_id
WHERE       c.name LIKE '%MyColumn_DontKnowWhichTableIs%'
ORDER BY    TableName