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

1/1/2016·1 min read
Responsive image
Photo by AltumCode on Unsplash

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;