레이블이 column인 게시물을 표시합니다. 모든 게시물 표시
레이블이 column인 게시물을 표시합니다. 모든 게시물 표시

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





MSSQL - Cursor vs Temp Table

#테이블 변수사용의 예 use pubs go declare @tmptable table (     nid int identity(1,1) not null,     title varchar (80) not null ) -- 테이블 변수 선언 inse...