如何在 SQL Server 数据库中查找特定列? [英] How to find specific column in SQL Server database?

查看:43
本文介绍了如何在 SQL Server 数据库中查找特定列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Server 2016 有没有什么方法或者工具可以根据名称在整个数据库中查找列?

Is there any way or tool in SQL Server 2016 to find a column in the entire database based on the name?

示例:找到 ProductNumber 并显示所有包含它的表

Example: find ProductNumber and it shows you all the table(s) that have it

推荐答案

您可以查询数据库的 information_schema.columns 表,该表保存了数据库中定义的所有列的架构结构.

You can query the database's information_schema.columns table which holds the schema structure of all columns defined in your database.

使用此查询:

select * from information_schema.columns where column_name = 'ProductNumber'

结果将为您提供列:

TABLE_NAMETABLE_CATALOGDATA_TYPE 以及此数据库列的更多属性.

TABLE_NAME, TABLE_CATALOG, DATA_TYPE and more properties for this database column.

这篇关于如何在 SQL Server 数据库中查找特定列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆