TSQL to get FieldName & FieldDescription within a SQL Server database
When you are documenting a database including the table-column information you need to have a description that can specify that so and so column is used for such a purpose. Think about accessing such information using Enterprise Manager or SS Management Studio, you have perform the chore by right-clicking on a table and choosing Design Table, on the Columns tab - "Description". Using the following TSQL you can get this information:
select cols.table_name, cols.column_name, sp.value as [description] from information_schema.columns cols
left join sysproperties sp on sp.id = object_id('syslogins') and sp.smallid=cols.ordinal_position and sp.name='MS_Description'
where cols.table_name='syslogins'
**__________________________________**
SQL Server MVP, Sr. DBA & industry expert.
-
Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.