Code Snippet - Use T-SQL to Search Table Name by Column Name

2015/12/311 min read
bookmark this

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
            ,ColumnName;