티스토리 뷰

반응형

with dataset as (

SELECT 

A.TABLE_NAME, 

C.VALUE AS TABLE_COMMENT,

cast(C.VALUE as varchar) as TABLE_COMMENT2,

A.COLUMN_NAME, A.DATA_TYPE, 

ISNULL(

CAST(A.CHARACTER_MAXIMUM_LENGTH AS VARCHAR),  

CAST(A.NUMERIC_PRECISION AS VARCHAR) + ',' +

CAST(A.NUMERIC_SCALE AS VARCHAR)

) AS COLUMN_LENGTH,

A.COLUMN_DEFAULT, A.IS_NULLABLE,

B.VALUE AS COLUM_COMMENT

FROM INFORMATION_SCHEMA.COLUMNS A 

LEFT OUTER JOIN SYS.EXTENDED_PROPERTIES B ON B.major_id = object_id(A.TABLE_NAME) 

AND A.ORDINAL_POSITION = B.minor_id

LEFT OUTER JOIN 

(

SELECT object_id(objname) AS TABLE_ID, VALUE

FROM ::FN_LISTEXTENDEDPROPERTY(NULL, 'User','dbo','table',NULL, NULL, NULL)

) C ON object_id(A.TABLE_NAME) = C.TABLE_ID

)

select * from dataset

where TABLE_COMMENT2 like '%테이블명%'

;

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함