# Retrieving MSSQL Column Descriptions

**URL:** <https://forum.inductiveautomation.com/t/retrieving-mssql-column-descriptions/54028>\
**Category:** Ignition\
**Created:** [December 13, 2021, 12:13am UTC](https://forum.inductiveautomation.com/t/retrieving-mssql-column-descriptions/54028 "2021-12-13T00:13:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewbrown](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@andrewbrown](https://forum.inductiveautomation.com/u/andrewbrown)\
**Post date:** [December 13, 2021, 12:13am UTC](https://forum.inductiveautomation.com/t/retrieving-mssql-column-descriptions/54028/1 "2021-12-13T00:13:16Z")

</div>

Howdy,

Having some troubles retrieving column descriptions from a MSSQL server. Attempting to get the descriptions of the columns so that if the structure is ever changed in the future it will map automatically rather than having to go and change the query’s and/or the views themselves.

Any help would be great.

```auto
SELECT COLUMN_NAME AS [Output]
    ,ORDINAL_POSITION
    ,prop.value AS [COLUMN_DESCRIPTION]
FROM INFORMATION_SCHEMA.TABLES AS tbl
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS col ON col.TABLE_NAME = tbl.TABLE_NAME
INNER JOIN sys.columns AS sc ON sc.object_id = object_id(tbl.table_schema + '.' + tbl.table_name)
    AND sc.NAME = col.COLUMN_NAME
LEFT JOIN sys.extended_properties prop ON prop.major_id = sc.object_id
    AND prop.minor_id = sc.column_id
    AND prop.NAME = 'MS_Description'
WHERE tbl.TABLE_NAME = 'LD_RecipeUDT'

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 14, 2021, 3:25pm UTC](https://forum.inductiveautomation.com/t/retrieving-mssql-column-descriptions/54028/2 "2021-12-14T15:25:54Z")

</div>

Are you getting any error(s), or what’s going wrong with your query?

In general this is _probably_ not a fruitful road to go down (in my experience) but knowing the particular error you’re seeing would help to troubleshoot.

---

<div class="post-metadata">

**Author:** ![andrewbrown](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@andrewbrown](https://forum.inductiveautomation.com/u/andrewbrown)\
**Post date:** [December 15, 2021, 1:58am UTC](https://forum.inductiveautomation.com/t/retrieving-mssql-column-descriptions/54028/3 "2021-12-15T01:58:54Z")

</div>

@paul-griffith Thanks for the reply, I did get it going. but have since decided to not go down this road.

I have decided to make a direct mapping based off, UDT tags, component names & column names. Seems to work alot nicer.
