SQL Server Extended Property 使用擴充屬性描述資料庫物件
2022-07-23
說明如何活用 SQL Server Extended Property 來標示資料庫物件用途,讓維護更為輕鬆省力 😉
說明
EXECUTE sp_addextendedproperty
N'MS_Description', '描述說明',
N'SCHEMA', N'結構描述名稱',
N'TABLE', N'資料表名稱',
N'COLUMN', N'欄位名稱'
SELECT
S.name as [Schema Name],
O.name AS [Object Name],
C.name as [Column Name] ,
EP.name, EP.value AS [Extended property]
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
Scripts 參考自 stackoverflow 上 Joel Cuff 以及 AMissico 在 How to get a list of all extended properties for all objects 的討論與分享 😃