添加描述的格式
exec sys.sp_addextendedproperty @name = N'MS_Description' ,@value = 'value',@level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name='process_evalwo',@level2type='COLUMN',@level2name='add_time'
添加字段的描述
exec sys.sp_addextendedproperty @name = N'MS_Description' ,@value = '创建时间',@level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name='process_evalwo',@level2type='COLUMN',@level2name='add_time'
添加表的描述
exec sys.sp_addextendedproperty @name = N'MS_Description' ,@value = '创建时间',@level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name='process_evalwo',@level2type=null,@level2name=null
查询表及字段的描述
SELECT * FROM sys.extended_properties WHERE major_id=OBJECT_ID('process_evalwo') SELECT * FROM sys.fn_listextendedproperty('MS_Description','SCHEMA','dbo','TABLE','process_evalwo','COLUMN','id')
查询表名描述 MS_Description
SELECT tbs.name 表名,ds.value 描述 FROM sys.extended_properties ds LEFT JOIN sysobjects tbs ON ds.major_id=tbs.id WHERE ds.minor_id=0 and tbs.name='ScheduleRecords';--表名
添加表的描述
EXECUTE sp_addextendedproperty N'MS_Description', N'菜单表', N'user', N'dbo', N'table', N'Menus', NULL, NULL;
更新表的描述
EXECUTE sp_updateextendedproperty N'MS_Description', N'菜单表', N'user', N'dbo', N'table', N'Menus', NULL, NULL;
查看表和字段的描述
select * from sys.extended_properties
查看扩展属性表
SELECT * FROM ::fn_listextendedproperty('MS_Description','SCHEMA','dbo','TABLE','process_evalwo','COLUMN','id')
介绍一个函数
OBJECT_ID('table_name') -- 根据表名查出这个表的ID
SQL参数前面添加“N”字符代表什么含义?
详见:添加描述详细使用方式