sql server2008给数据表,字段,添加修改注释
1、sqlserver用语句给表注释
EXECUTE sp_addextendedproperty N'MS_Description', N'表注释', N'user', N'dbo', N'table', N'表名', NULL, NULL
2、sqlserver用语句给表的“字段”注释
EXECUTE sp_addextendedproperty N'MS_Description', N'字段注释', N'user', N'dbo', N'table', N'表名', N'column', N'字段名'
3、查看sqlserver注释
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 = '表名'
出处:http://begoodluck.blog.163.com/blog/static/20450728020141191412788/
===========================================================================
1、 给表添加注释
1
2
3
4
|
-- 表加注释 EXEC sys.sp_addextendedproperty @ name =N 'MS_Description' , @value=N '注释内容' , @level0type=N 'SCHEMA' ,@level0name=N 'dbo' , @level1type=N 'TABLE' ,@level1name=N '表名' --例如: EXEC sys.sp_addextendedproperty @ name =N 'MS_Description' , @value=N '系统设置表' , @level0type=N 'SCHEMA' ,@level0name=N 'dbo' , @level1type=N 'TABLE' ,@level1name=N 'CM01_SYSTEM' |
2、给表的“字段”添加注释
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
--新增数据字段注释 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' |
出处:http://www.cnblogs.com/Gold-fangjin/p/5900970.html
关注我】。(●'◡'●)
如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的【因为,我的写作热情也离不开您的肯定与支持,感谢您的阅读,我是【Jack_孟】!
本文来自博客园,作者:jack_Meng,转载请注明原文链接:https://www.cnblogs.com/mq0036/p/6361866.html
【免责声明】本文来自源于网络,如涉及版权或侵权问题,请及时联系我们,我们将第一时间删除或更改!
posted on 2017-02-02 23:40 jack_Meng 阅读(15746) 评论(0) 编辑 收藏 举报