Column description

  • BG0AWI

    SSC Veteran

    Points: 289

    Is there a way in T-sql get the defined COLUMN DESCRIPTION text (One of the Column properties when you're in 'design table'-mode)??

    /Anders

    AW


    AW

  • Antares686

    SSC Guru

    Points: 125444

    You could look at the syscomments table for the data or use the preferred fn_listextendedproperty which works but takes a bit to use, check out BOL for more information.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • G.R.Prithiviraj Kulasingham

    SSCarpal Tunnel

    Points: 4104

    The SysProperties Table has the description.

    the name should be 'MS_Description'

    Here I have a sample code

    select O.Name [Table_name], c.name [Column_Name],

    p.Value [description]

    From dbo.SysObjects O,

    dbo.SysColumns C Left Outer Join

    (select id, smallid, name, Value from dbo.SysProperties

    Where Name = 'MS_Description') P

    On P.id = c.id and P.smallid = C.Colid

    Where O.id = C.id and ObjectProperty(O.id, 'ISUSERTABLE')=1

    Order By O.name, c.colid

    If you have different users owning tables with same file names You may have to add the table_schema too.

     
     

    Cheers,
    Prithiviraj Kulasingham

    http://preethiviraj.blogspot.com/

  • Antares686

    SSC Guru

    Points: 125444

    Sorry about that sysporperties is correct. Having a murphy day here. ANyway you should learn to use the function thou as MS states system changes can change between versions but functions should remain the same.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

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

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