码迷,mamicode.com
首页 > 数据库 > 详细

sql server2008给数据表,字段,添加修改注释

时间:2016-09-23 18:04:28      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:

1 -- 表加注释
2 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘注释内容‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘表名‘
3 --例如:
4 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘系统设置表‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CM01_SYSTEM‘

  

  

--新增数据字段注释

EXECUTE sp_addextendedproperty ‘MS_Description‘, ‘收益浮动表‘, ‘user‘, ‘dbo‘, ‘table‘, ‘COM_IncomeFloat‘, ‘column‘, ‘RowId‘;
--修改数据字段注释

EXECUTE sp_updateextendedproperty ‘MS_Description‘, ‘收益浮动表‘, ‘user‘, ‘dbo‘, ‘table‘, ‘COM_IncomeFloat‘, ‘column‘, ‘RowId‘;

MS_Description :调用的Proc

COM_IncomeFloat :表名

RowId :表字段

查询字段注释

SELECT
A.name AS table_name,
B.name AS column_name,
C.value AS column_description
FROM sys.tables A
INNER JOIN sys.columns B ON B.object_id = A.object_id
LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id
WHERE A.name = ‘COM_IncomeFloat‘

  

sql server2008给数据表,字段,添加修改注释

标签:

原文地址:http://www.cnblogs.com/Gold-fangjin/p/5900970.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!