Tuesday, February 25, 2014

get column name from column description in mssql

 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 = 'actBill'
                                AND sep.value = 'aaa'  ---description of the column

No comments:

Post a Comment