Use a Query to access column description in SQL

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)