2009年5月28日

取得 SQL Server Table 和 Column 的註解


-- 取得 Table 註解
SELECT
sysobjects.name AS tableName,
sysproperties.value AS comment
FROM
sysobjects
INNER JOIN
sysproperties
ON sysobjects.id = sysproperties.id
WHERE
sysproperties.smallid = 0
;

-- 取得 Column 註解
SELECT
sysobjects.name AS tableName,
syscolumns.name AS columnName,
sysproperties.value AS comment
FROM
syscolumns
INNER JOIN
sysproperties
ON syscolumns.id = sysproperties.id
AND syscolumns.colid = sysproperties.smallid
INNER JOIN
sysobjects
ON syscolumns.id = sysobjects.id
;

沒有留言:

網誌存檔