Re: How do I get all column descriptions from a schema.table?



Hi David,

The error is thrown because except column description, the
HumanResources.Employee data table in Adventureworks database has index
description as well. So the subquery will return more than one value.

To avoid this issue and only retrieve the column description, we can filter
the data by (class) = 1, because the column class is equal to 1 in the
sys.entended_properties
(http://msdn.microsoft.com/en-us/library/ms177541.aspx).
======================================================
SELECT sys.columns.name AS ColumnName,
sys.types.name AS ColumnType,
(SELECT value FROM sys.extended_properties
WHERE (major_id = sys.columns.object_id) AND
(minor_id = sys.columns.column_id) AND
((class) = 1)) AS ColumnDescription
FROM sys.columns
INNER JOIN sys.tables ON sys.columns.object_id = sys.tables.object_id
INNER JOIN sys.types ON sys.columns.user_type_id = sys.types.user_type_id
INNER JOIN sys.schemas ON sys.tables.schema_id = sys.schemas.schema_id
WHERE (sys.tables.name = 'Employee') AND (sys.schemas.name =
'HumanResources')
======================================================

Besides, to retrieve the other descriptions, we can filter the by setting
the (class) value, e.g. Database = 0, Schema = 3, index = 7 and etc.

If you have any questions, please feel free to let me know.

Have a nice day!

Best Regards,
Lingzhi Sun
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

.



Relevant Pages

  • Re: Join and Replace with SQl 2005?
    ... The third clause (contained in ... the NOT EXISTS) did not seem to filter out the data. ... Microsoft Online Community Support ... Please feel free to let my manager ...
    (microsoft.public.sqlserver.programming)
  • Re: Access 2007 Form Datasheet
    ... drop down arrows that show up with a datasheet form to filter the columns ... Microsoft Online Community Support ... Please feel free to let my manager ...
    (microsoft.public.access.forms)
  • Re: Form Bound to SQL Indexed View
    ... returned with the 'save' and Access could then retrieve the complete new ... Once you finished inputting a new row, ... Microsoft Online Community Support ... Please feel free to let my manager ...
    (microsoft.public.access.forms)
  • Re: Getting FK->PK relationships
    ... we can use it to retrieve the ... Colbert Zhou ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ...
    (microsoft.public.data.odbc)
  • RE: Can you supress specific XML Elements when using LINQ to XML
    ... If I understand the scenario correctly, you plan to filter the RunningTime ... <MediaAsset> ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ...
    (microsoft.public.vsnet.general)

Loading