SqlServer帮助中对扩展属性的描述是:
The Extended Properties property sets or retrieves provider-specific connection information that cannot be explicitly described through the property mechanism.
对于扩展属性有如下操作:
exec sp_addextendedproperty N'MS_Description', N'字段描述', N'user', N'dbo',
N'table', N'表名', N'column', N'字段名'
GO
例如:EXEC sp_addextendedproperty N'MS_Description',N'地址',N'user', dbo,N'table',
N'a', N'column', a_add
GO--我的表是a,要给字段a_add加上字段描述:地址
其他相关:
删除:
EXEC sp_dropextendedproperty N'MS_Description',N'user', dbo,N'table', N'表名',
N'column', 字段名
修改:
EXEC sp_updateextendedproperty N'MS_Description', N'字段描述', N'user',
dbo,N'table',N'表名', 'column', 字段
至于查询出来,sql server有提供系统函数fn_listextendedproperty ():
--获取某一个字段的描述
SELECT *
FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table', '表名', 'column',
default)--其他变数,按照你的要求你照写即可,只要表名换成你的
where objname = '字段名'
另外也可以自己查询系统表:
SELECT o.name AS tableName, c.name AS columnName, p.[value] AS Description
FROM sysproperties p INNER JOIN
sysobjects o ON o.id = p.id INNER JOIN
syscolumns c ON p.id = c.id AND p.smallid = c.colid
WHERE (p.name = 'MS_Description')
ORDER BY o.name