Accessing the Description property of a field

  • In Enterprise Manager, in table design, you can enter a Description.

    Does anyone know a query that will return the columns of a of a table and show the 'Description' property of the fields? 

  • these descriptions are stored in the sysproperties system table (don't know if they are also stored in any INFORMATION_SCHEMA view) along with the object id of the table...

    this query should (hopefully) return the column name and the description (if any):

    DECLARE @TableName Varchar(100)

    SET @TableName = 'xxxxxxxx'

    SELECT

     SC.name,

     SP.value

    FROM syscolumns SC LEFT OUTER JOIN sysproperties SP ON

    SP.id = SC.id

    WHERE SC.id = object_id(@TableName)

     

     

     

  • I've found a small change should eliminate repeating rows:

    DECLARE @TableName Varchar(100)

    SET @TableName = 'ASection'

    SELECT

     SC.name,

     SP.value

    FROM syscolumns SC LEFT OUTER JOIN sysproperties SP ON

    SP.id = SC.id

    and SC.colid = SP.smallid

    WHERE SC.id = object_id(@TableName)

  • Thanks guys.  This is exactly what I needed.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply