--為字段新增注釋
--格式如右:execute sp_addextendedproperty 'ms_description','字段備註資訊','user','dbo','table','字段所屬的表名','column','新增注釋的欄位名';
execute sp_addextendedproperty 'ms_description','add by liyc. 診斷類別碼','user','dbo','table','diagrecord','column','diagtypecode';
--修改字段注釋
execute sp_updateextendedproperty 'ms_description','add by liyc.','user','dbo','table','diagrecord','column','diagtypecode';
--刪除字段注釋
execute sp_dropextendedproperty 'ms_description','user','dbo','table','diagrecord','column','diagtypecode';
-- 新增表注釋
execute sp_addextendedproperty 'ms_description','診斷記錄檔案','user','dbo','table','diagrecord',null,null;
-- 修改表注釋
execute sp_updateextendedproperty 'ms_description','診斷記錄檔案1','user','dbo','table','diagrecord',null,null;
-- 刪除表注釋
execute sp_dropextendedproperty 'ms_description','user','dbo','table','diagrecord',null,null;
-- 說明:
-- 1.增加、修改、刪除注釋呼叫不同的儲存過程
-- 2.增加、修改注釋呼叫的儲存過程引數數量和含義相同,刪除備註比前兩者少了乙個「備註內容」的引數
-- 3.為表新增注釋相比於為字段新增注釋,最後兩個引數為null
--檢視表的所有字段注釋
use healthcare;
select [columnname] = [columns].name ,
[description] = [properties].value,
[systemtypename] = [types].name ,
[precision] = [columns].precision ,
[scale] = [columns].scale ,
[maxlength] = [columns].max_length ,
[isnullable] = [columns].is_nullable ,
[isrowguidcol] = [columns].is_rowguidcol ,
[isidentity] = [columns].is_identity ,
[iscomputed] = [columns].is_computed ,
[isxmldocument] = [columns].is_xml_document
from sys.tables as [tables]
inner join sys.columns as [columns] on [tables].object_id = [columns].object_id
inner join sys.types as [types] on [columns].system_type_id = [types].system_type_id
and is_user_defined = 0
and [types].name <> 'sysname'
left outer join sys.extended_properties as [properties] on [properties].major_id = [tables].object_id
and [properties].minor_id = [columns].column_id
and [properties].name = 'ms_description'
where [tables].name ='表名' -- and [columns].name = '欄位名'
order by [columns].column_id
--檢視表的注釋
use healthcare;
select isnull(value,'') from sys.extended_properties ex_p where ex_p.minor_id=0
and ex_p.major_id in (select id from sys.sysobjects a where a.name='表名')
Sqlserver給表名和列名新增注釋
一 表注釋 1 新增 固定寫法 exec sys.sp addextendedproperty name n ms description level1type n table level0type n schema level0name n dbo 自定義 value n 注釋內容 level1n...
sqlserver欄位新增注釋方法
大部分網路給出的是如下方法,也是sqlserver生成 標準寫法 新增表注釋 exec sys.sp addextendedproperty name n ms description value n 人員資訊 level0type n schema level0name n dbo level1t...
mysql約規表注釋 mysql 表注釋和字段注釋
1 建立表的時候寫注釋 create table test1 field name int comment 欄位的注釋 comment 表的注釋 2 修改表的注釋 alter table test1 comment 修改後的表的注釋 3 修改欄位的注釋 alter table test1 modif...