1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| create table test ( id varchar(200) primary key not null, sort int, name varchar(200), )
EXECUTE sp_addextendedproperty N'MS_Description',N'字段备注信息',N'SCHEMA',N'dbo',N'table',N'表名',N'column',N'添加注释的字段名';
EXECUTE sp_updateextendedproperty N'MS_Description',N'修改的注释内容',N'SCHEMA',N'dbo',N'table',N'表名',N'column',N'添加注释的字段名';
EXECUTE sp_dropextendedproperty N'MS_Description',N'SCHEMA',N'dbo',N'table',N'表名',N'column',N'添加注释的字段名';
EXECUTE sp_addextendedproperty N'MS_Description',N'注释内容',N'SCHEMA',N'dbo',N'table',N'表名',NULL, NULL;
EXECUTE sp_updateextendedproperty N'MS_Description',N'修改注释内容',N'SCHEMA',N'dbo',N'table',N'表名',NULL, NULL;
execute sp_dropextendedproperty N'MS_Description',N'SCHEMA',N'dbo',N'table',N'表名',NULL, NULL;
SELECT obj.name AS [TableName],pro.value AS [Description] FROM sys.objects obj LEFT JOIN sys.extended_properties pro ON obj.object_id=pro.major_id WHERE obj.type='u'
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 = '表名'
|