2018년 4월 4일 수요일

DB - MSSQL - tables & columns description



[테이블 및 컬럼 설명 보기]

select a.table_name, a.table_comment, b.column_name, b.column_description
from (
SELECT
tbl.name as table_name
, p.value AS table_comment
FROM sys.tables AS tbl
inner join sys.schemas as s on s.schema_id = tbl.schema_id
LEFT JOIN sys.extended_properties AS p ON p.major_id = tbl.object_id AND p.minor_id = 0 AND p.class = 1 AND p.name = 'MS_Description'
where p.value is not null
) a
left join (
SELECT O.name AS [table_name], c.name as [column_name], ep.value AS [column_description]
FROM sys.extended_properties EP
LEFT JOIN sys.all_objects O ON ep.major_id = O.object_id
LEFT JOIN sys.schemas S on O.schema_id = S.schema_id
LEFT JOIN sys.columns AS c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
where c.name is not null
) b on a.table_name = b.table_name
where b.column_name is not null
order by a.table_name, b.column_name





댓글 없음:

댓글 쓰기

Flutter #0

[Flutter 교육] Dart vs JavaScript 타입 시스템 비교 1. 기본 타입 차이 숫자 타입 // Dart int integerNumber = 42; // 정수 double floatingPoint = 3.14; // 부...