我正在尝试使用INFORMATION_SCHEMA访问列描述属性
我以前创建了此查询以获取列名称,但我无法弄清楚如何获取列的描述
SELECT COLUMN_NAME AS Output,ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_NAME = @Tablename) AND (ORDINAL_POSITION = @Location)
这是描述在字段属性上的位置
解决方法
如果通过’description’表示’描述’在设计模式下显示在sql Management Studio中,这里是:
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