MSSQL 添加字段说明
程序员文章站
2023-11-20 19:45:34
--字段添加说明 exec sp_addextendedproperty 'ms_description', '要添加的说明', 'user', dbo, 'table',...
--字段添加说明
exec sp_addextendedproperty 'ms_description', '要添加的说明', 'user', dbo, 'table', 表名, 'column', 列名
--删除字段说明
exec sp_dropextendedproperty 'ms_description', 'user', dbo, 'table', 表名, 'column', 字段名
--查看字段说明
select
[table name] = i_s.table_name,
[column name] = i_s.column_name,
[description] = s.value
from
information_schema.columns i_s
left outer join
sysproperties s
on
s.id = object_id(i_s.table_schema+'.'+i_s.table_name)
and s.smallid = i_s.ordinal_position
and s.name = 'ms_description'
where
objectproperty(object_id(i_s.table_schema+'.'+i_s.table_name), 'ismsshipped')=0
and i_s.table_name = 'jobs'
order by
i_s.table_name, i_s.ordinal_position
exec sp_addextendedproperty 'ms_description', '要添加的说明', 'user', dbo, 'table', 表名, 'column', 列名
--删除字段说明
exec sp_dropextendedproperty 'ms_description', 'user', dbo, 'table', 表名, 'column', 字段名
--查看字段说明
复制代码 代码如下:
select
[table name] = i_s.table_name,
[column name] = i_s.column_name,
[description] = s.value
from
information_schema.columns i_s
left outer join
sysproperties s
on
s.id = object_id(i_s.table_schema+'.'+i_s.table_name)
and s.smallid = i_s.ordinal_position
and s.name = 'ms_description'
where
objectproperty(object_id(i_s.table_schema+'.'+i_s.table_name), 'ismsshipped')=0
and i_s.table_name = 'jobs'
order by
i_s.table_name, i_s.ordinal_position