检索包含已知列的表
此查询将返回给定列名称的所有 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%'
此查询将返回给定列名称的所有 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%'