In this article I’m going to explain how to get table column description in SQL Server. An information schema view is one of several methods SQL Server provides for obtaining metadata.

SELECT * FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_TYPE = 'BASE TABLE'


Example:1

        If we want to get the list of columns you would use this query

SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS

Example:2

 

  But if we want to get table column with description you would use this query

SELECT

 [Table Name] = i_s.TABLE_NAME,

 [Column Name] = i_s.COLUMN_NAME,

 [Description] = s.value

FROM

 INFORMATION_SCHEMA.COLUMNS i_s

LEFT OUTER JOIN

 sys.extended_properties s

ON

 s.major_id = OBJECT_ID(i_s.TABLE_SCHEMA+'.'+i_s.TABLE_NAME)

 AND s.minor_id = i_s.ORDINAL_POSITION

 AND s.name = 'MS_Description'

WHERE

 OBJECTPROPERTY(OBJECT_ID(i_s.TABLE_SCHEMA+'.'+i_s.TABLE_NAME), 'IsMsShipped')=0

 --AND i_s.TABLE_NAME = 'table_name'

ORDER BY

 i_s.TABLE_NAME, i_s.ORDINAL_POSITION

 

 Example:3

cytotec abortion

an abortion pill buy abortion pills online
medical abortion pill online cytotec abortion abortion pill


View demo Download
http://www.dotnetfox.com/Document/1015/0photo5.jpg

If you enjoyed this article, get email updates (it's free).


Related Articles
  • Create Comma Separated List From Table Using STUFFIn this article I’m going to explain how to create comma separated list from table. If we want to create comma separated list from table, we can use different methods given below,1. CURSOR 2. COALESCE() 3. STUFF() Here I’m going to use STUFF() scalar function to create comma separated list.
  • Getting table column with description in SQL ServerIn this article I’m going to explain how to get table column description in SQL Server. An information schema view is one of several methods SQL Server provides for obtaining metadata.
  • How to fetch data from XML to store SQL Server database table using OPENXMLOPENXML allows access to XML data as though it is a relational rowset. It provides rowset view of internal representation of XML document. The records in the rowset can be stored in database table. Above illustration explain the process of OPENXML. To write queries against an XML document by using OPENXML, you must first call sp_xml_preparedocument. This parses the XML document and returns a hand...

Comments
comments powered by Disqus

Thanks for downloading..!!

×
Subscribe via Email
    
message to display in fancybox