Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show Table Structure with Description 2

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
I'm trying to get the table structure including the field descriptions.
There are several examples of how to do this but how do I get the field description included in the information schema ?

Code:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'MyTable'
ORDER BY ORDINAL_POSITION

Any help would be appreciated
 
Try this

Code:
Select  C.*, p.Value As FieldDescription
From    Information_Schema.Columns C
        Left Join sys.extended_properties P
          On  object_id(Table_Schema + '.' + Table_Name)  = P.major_id
          And C.Ordinal_Position = p.minor_id
          And p.name = 'MS_DESCRIPTION'
Order By TABLE_SCHEMA,
	TABLE_NAME,
	ORDINAL_POSITION

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top