解决方法
使用扩展属性.例如,要将扩展属性添加到dbo模式中的表中,可以使用:
EXEC sys.sp_addextendedproperty @name=N'<NameOfProp>',@value=N'<Value>',@level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name=N'<Table>'
您可以更新它们:
EXEC sys.sp_updateextendedproperty @name=N'MS_Description',@value=N'My Description',@level1name=N'<YOUR TABLE NAME>'
你可以读取它们:
SELECT * FROM fn_listextendedproperty (NULL,'schema','dbo','table','<yourtable>',default,default);
要么
SELECT p.name AS [Name],p.value FROM sys.tables AS tbl INNER JOIN sys.extended_properties AS p ON p.major_id=tbl.object_id AND p.minor_id=0 AND p.class=1 WHERE (tbl.name=N'<yourtablename>' and SCHEMA_NAME(tbl.schema_id)=N'dbo') ORDER BY [Name] ASC