/************************************************************ * Code formatted by SoftTree SQL Assistant ?v5.0.97 * Time: 2013-3-4 13:28:08 ************************************************************/ --获取、增加、修改、删除sqlserver字段描述 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') AND (c.name = 'province') AND (o.name = 'ip_address') ORDER BY o.name --选取表ip_address中 字段province的描述 --创建表及描述信息 CREATE TABLE 表 ( a1 VARCHAR(10), a2 CHAR(2) ) --为表添加描述信息 EXECUTE sp_addextendedproperty 'MS_Description', '人员信息表', 'user', 'dbo', 'table', '表', NULL, NULL --为字段a1添加描述信息 EXECUTE sp_addextendedproperty 'MS_Description', '姓名', 'user', 'dbo', 'table', '表', 'column', 'a1' EXECUTE sp_addextendedproperty 'MS_Description', '测试', 'user', 'dbo', 'table', 'HR_Employees', 'column', 'test' --为字段a2添加描述信息 EXECUTE sp_addextendedproperty 'MS_Description', '性别', 'user', 'dbo', 'table', '表', 'column', 'a2' --更新表中列a1的描述属性: EXEC sp_updateextendedproperty 'MS_Description', '字段1', 'user', dbo, 'table', '表', 'column', a1 --删除表中列a1的描述属性: EXEC sp_dropextendedproperty 'MS_Description', 'user', dbo, 'table', '表', 'column', a1 --删除测试 DROP TABLE