* COLUMN COMMNET SELECT QUERY
*=====================================================================================================================*/
SELECT
tb.name, -- TABLE NAME
c.name, --FIELD
t.name AS typename, -- TYPE
c.max_length AS length, -- SIZE
c.is_nullable, -- NULL / NOT NULL
c.is_identity, -- Identity Yes/No
CAST(p.[value] AS varchar) AS cmt --FIELD COMMENT
FROM sys.columns c
INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
INNER JOIN sys.objects tb ON tb.object_id = c.object_id
INNER JOIN sys.schemas u ON u.schema_id = tb.schema_id
LEFT OUTER JOIN sys.extended_properties p ON p.major_id = c.object_id
AND p.minor_id = c.column_id
AND p.class = 1
AND p.name = 'MS_Description'
WHERE tb.name = 'FM_EXP_TOOL' AND u.name = 'dbo'
ORDER BY c.column_id
/**=====================================================================================================================
* TABLE COMMNET SELECT QUERY
*=====================================================================================================================*/
SELECT
o.name,
u.name AS owner,
o.type,
CAST(p.[value] AS varchar) AS cmt
FROM sys.tables o INNER JOIN sys.schemas u ON u.schema_id = o.schema_id
LEFT OUTER JOIN sys.extended_properties p ON p.major_id = o.object_id AND p.minor_id = 0 AND p.name = 'MS_Description'
WHERE o.name = 'FM_EXP_TOOL' AND u.name = 'dbo'
/**=====================================================================================================================
* PROCEDURE COMMNET SELECT QUERY
*=====================================================================================================================*/
SELECT
o.name,
u.name AS owner,
o.type,
CAST(p.[value] AS varchar) AS cmt
FROM sys.objects o INNER JOIN sys.schemas u ON u.schema_id = o.schema_id
LEFT OUTER JOIN sys.extended_properties p ON p.major_id = o.object_id
AND p.minor_id = 0 AND p.name = 'MS_Description'
WHERE o.type IN ('P', 'RF') AND o.name = 'CODE_ACTION' AND u.name = 'dbo'
'wow db Log > ms-sql' 카테고리의 다른 글
[팁] 트랜잭션 로그 줄이기 실습 (0) | 2008.05.27 |
---|---|
[팁] 이젠 외우자.. ALTER TABLE (0) | 2008.04.29 |
[펌] Group by 와 DateTime 가지고 놀기 (3) | 2008.03.17 |
네트웍드라이브에 MSSQL 백업하기 (0) | 2008.03.13 |
[팁] MSSQL 쿼리 팁 (0) | 2008.03.11 |