Click here to Skip to main content
Click here to Skip to main content

Tagged as

Preparing “Data Dictionary” using SQL Query

, 7 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.


Documentation plays an important role whereas "Data Dictionary" gives the idea about data stored using application.


So here is the query for preparing the data dictionary of any database.
SELECT [Table Name] = OBJECT_NAME(c.object_id)
,[Column Name] =
,[Data Type] =
,[Size] = c.max_length
,[Description] = isnull(ex.value,'')
FROM sys.columns c
LEFT OUTER JOIN sys.extended_properties ex ON (ex.major_id = c.object_id AND ex.minor_id = c.column_id AND = 'MS_Description')
INNER JOIN sys.types t ON c.system_type_id = t.system_type_id
WHERE OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) in (select name from sys.tables where type= 'U')
ORDER BY OBJECT_NAME(c.object_id), c.column_id


You can add/remove columns which you want to include from the definition of the table (if any other required - i.e. if you want to display whether the column is null/not null, just include the field from sys.objects table and so on).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chirag Vidani
Software Developer (Senior) Cygnet Infotech Pvt. Ltd.
India India
No Biography provided
Follow on   Twitter

Comments and Discussions

GeneralReason for my vote of 5 Nice my 5 PinmemberTejas_Vaishnav18-Nov-11 19:03 
GeneralReason for my vote of 5 thanks Pinmembermagicpapacy11-Oct-11 22:07 
GeneralReason for my vote of 5 Nice Pinmemberkiran dangar7-Oct-11 0:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150301.1 | Last Updated 7 Oct 2011
Article Copyright 2011 by Chirag Vidani
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid