Selecting Tables Containing A Column Name: Catalog Views Like
Selecting Tables Containing A Column Name: Catalog Views Like
SELECT
sys.columns.name AS ColumnName,
tables.name AS TableName
FROM
sys.columns
JOIN sys.tables ON
sys.columns.object_id = tables.object_id
WHERE
sys.columns.name = 'ColumnName'
However, this query will only find exact matches of the column name. If we want to
find partial matches, we can use LIKE and % wildcard characters instead:
SELECT
sys.columns.name AS ColumnName,
tables.name AS TableName
FROM
sys.columns
JOIN sys.tables ON
sys.columns.object_id = tables.object_id
WHERE
sys.columns.name LIKE '%ColumnName%'