I want to show all tables that have specified column name

前端 未结 8 2422
粉色の甜心
粉色の甜心 2020-12-12 23:49

How can I get a list of all the tables that have a specific column name?

8条回答
  •  旧巷少年郎
    2020-12-13 00:21

    SELECT t.name AS table_name,
    SCHEMA_NAME(schema_id) AS schema_name,
    c.name AS column_name,*
    FROM sys.tables AS t
    INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID 
    WHERE c.name LIKE '%YOUR_COLUMN%' 
    ORDER BY schema_name, table_name;
    

    In depth article by SQL Authority

提交回复
热议问题