标签:
本篇基本完全参考:sql--sp_addextendedproperty和sp_updateextendedproperty (Transact-SQL)
三个存储过程用法一样,以sp_addextendedproperty为例:
sp_addextendedproperty [ @name = ]{ ‘property_name‘ } [ , [ @value = ]{ ‘value‘ } [, [ @level0type = ]{ ‘level0_object_type‘ } , [ @level0name = ]{ ‘level0_object_name‘ } [, [ @level1type = ]{ ‘level1_object_type‘ } , [ @level1name = ]{ ‘level1_object_name‘ } [, [ @level2type = ]{ ‘level2_object_type‘ } , [ @level2name = ]{ ‘level2_object_name‘ } ] ] ] ]
参数:
if exists(select 1 from sys.tables where object_id=object_id(‘TestTable‘)) begin drop table TestTable end create table TestTable ( ColumnA varchar(50), ColumnB varchar(50) )
2.为ColumnA列添加注释:
exec sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘列A的注释‘, @level0type=N‘SCHEMA‘, @level0name=N‘dbo‘, @level1type=N‘TABLE‘, @level1name=N‘TestTable‘, @level2type=N‘COLUMN‘, @level2name=N‘ColumnA‘
3.查看结果:
或者执行sql语句:
select B.Name,A.value from sys.extended_properties A inner join sys.columns B on A.major_id=B.object_id and A.minor_id=B.column_id where A.major_id=object_id(‘TestTable‘)
结果:
标签:
原文地址:http://www.cnblogs.com/walden1024/p/4545688.html