[MS-SQL] 테이블의 컬럼 설명까지 보여주는 쿼리

Posted by MD워시퍼
2011. 9. 2. 00:01 Study/MS-SQL
728x90
SELECT  
   [Table Name] = OBJECT_NAME(c.object_id), 
   [Column Name] = c.name, 
   [Description] = 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 ex.name = 'MS_Description'
WHERE  
   OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0  
   AND OBJECT_NAME(c.object_id) = '<<Table_Name>>' 
ORDER  
   BY OBJECT_NAME(c.object_id), c.column_id