gpt4 book ai didi

sql - 查找包含具有指定名称的列的所有表 - MS SQL Server

转载 作者:行者123 更新时间:2023-12-01 16:14:09 39 4
gpt4 key购买 nike

是否可以查询包含以下列的表名

LIKE '%myName%'

最佳答案

搜索表:

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

搜索表和 View :

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

关于sql - 查找包含具有指定名称的列的所有表 - MS SQL Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4849652/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com