來源:Find all tables containing column with specified name - MS SQL Server - Stack Overflow
 

搜尋所有 Table

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 '%MyName%'
ORDER BY    TableName
            ,ColumnName;

 

搜尋所有 Table, View

SELECT      TABLE_NAME AS  'TableName'
            ,COLUMN_NAME AS 'ColumnName'
FROM        INFORMATION_SCHEMA.COLUMNS
WHERE       COLUMN_NAME LIKE '%MyName%'
ORDER BY    TableName
            ,ColumnName;

 

文章標籤
創作者介紹
創作者 Robert 的頭像
Robert

Robert 的部落格

Robert 發表在 痞客邦 留言(0) 人氣()