开发者

SQL query to find all tables in a database that have a column with a specific name

开发者 https://www.devze.com 2023-02-04 11:58 出处:网络
What query can I run on a 开发者_开发问答database that will tell me which tables in that database have a column named \"RCPTNMBR\"?Most databases support this:

What query can I run on a 开发者_开发问答database that will tell me which tables in that database have a column named "RCPTNMBR"?


Most databases support this:

SELECT 
    table_name 
FROM 
    information_schema.columns 
WHERE
    column_name = 'x'


Give this a try

SELECT t.name as TableName, c.name as ColumnName
FROM sys.tables t
JOIN sys.columns c ON t.object_id = c.object_id
WHERE c.name = 'RCPTNMBR'
0

精彩评论

暂无评论...
验证码 换一张
取 消