使用查询访问 SQL 中的列描述 [英] Use a Query to access column description in SQL
本文介绍了使用查询访问 SQL 中的列描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 INFORMATION_SCHEMA 访问列描述属性
I am trying to access the Column description properties using the INFORMATION_SCHEMA
我过去创建了这个查询来获取列名,但我不知道如何获取列的描述
I have created this Query in the past to get the column name but i can not figure out how to get description of the column
SELECT COLUMN_NAME AS Output, ORDINAL_POSITION
FROM INFORMATION_SCHEMA.COLUMNS
WHERE (TABLE_NAME = @Tablename) AND (ORDINAL_POSITION = @Location)
这是描述在字段属性上的位置
This is where the Description is on the field properties
推荐答案
如果描述"是指在设计模式下 SQL Management Studio 中显示的描述",则是:
If by 'description' you mean 'Description' displayed in SQL Management Studio in design mode, here it is:
select
st.name [Table],
sc.name [Column],
sep.value [Description]
from sys.tables st
inner join sys.columns sc on st.object_id = sc.object_id
left join sys.extended_properties sep on st.object_id = sep.major_id
and sc.column_id = sep.minor_id
and sep.name = 'MS_Description'
where st.name = @TableName
and sc.name = @ColumnName
这篇关于使用查询访问 SQL 中的列描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文