檢索包含已知列的表

此查詢將返回給定列名稱的所有 COLUMNS 及其關聯的 TABLES。它旨在向你展示哪些表(未知)包含指定的列(已知)

SELECT 
    c.name AS ColName, 
    t.name AS TableName
FROM 
    sys.columns c
    JOIN sys.tables t ON c.object_id = t.object_id
WHERE 
    c.name LIKE '%MyName%'