先看添加与删除字段描述

EXEC sys.sp_addextendedproperty @name = N'MS_Description',
--添加Type字段说明
@value = N'屏蔽类型对应值(类型对应Id)',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'ForbiddenType',
@level2type = N'COLUMN',
@level2name = N'TypeId' --删除表中列Type的描述属性:
EXEC sp_dropextendedproperty 'MS_Description',
'SCHEMA',
dbo,
'TABLE',
'ForbiddenType',
'COLUMN',
TYPE

看下面的实例:

--创建表及描述信息 

create table 表(a1 varchar(),a2 char()) 

--为表添加描述信息
EXECUTE sp_addextendedproperty N'MS_Description', '人员信息表', N'user', N'dbo', N'table', N'表', NULL, NULL

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生成记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CrabRequisition'
GO


--为字段a1添加描述信息
EXECUTE sp_addextendedproperty N'MS_Description', '姓名', N'user', N'dbo', N'table', N'表', N'column', N'a1' EXECUTE sp_addextendedproperty N'MS_Description', '测试', N'user', N'dbo', N'table', N'HR_Employees', N'column', N'test' --为字段a2添加描述信息
EXECUTE sp_addextendedproperty N'MS_Description', '性别', N'user', N'dbo', N'table', N'表', N'column', N'a2'
--更新表中列a1的描述属性:
EXEC sp_updateextendedproperty 'MS_Description','字段1','user',dbo,'table','表','column',a1 --删除表中列a1的描述属性:
EXEC sp_dropextendedproperty 'MS_Description','user',dbo,'table','表','column',a1
--表描述
SELECT
tbs.name 表名
,ds.value 描述
FROM sys.extended_properties ds
LEFT JOIN sysobjects tbs
ON ds.major_id = tbs.id
WHERE ds.minor_id =
AND tbs.name = 'Warrant_BaseInfo';--表名
--快速查看表结构
SELECT
CASE
WHEN col.colorder = THEN obj.name
ELSE ''
END AS 表名
,col.colorder AS 序号
,col.name AS 列名
,ISNULL(ep.[value], '') AS 列说明
,t.name AS 数据类型
,col.length AS 长度
,ISNULL(COLUMNPROPERTY(col.id, col.name, 'Scale'), ) AS 小数位数
,CASE
WHEN COLUMNPROPERTY(col.id, col.name, 'IsIdentity') = THEN '√'
ELSE ''
END AS 标识
,CASE
WHEN EXISTS (SELECT FROM dbo.sysindexes si
INNER JOIN dbo.sysindexkeys sik
ON si.id = sik.id
AND si.indid = sik.indid
INNER JOIN dbo.syscolumns sc
ON sc.id = sik.id
AND sc.colid = sik.colid
INNER JOIN dbo.sysobjects so
ON so.name = si.name
AND so.xtype = 'PK'
WHERE sc.id = col.id
AND sc.colid = col.colid) THEN '√'
ELSE ''
END AS 主键
,CASE
WHEN col.isnullable = THEN '√'
ELSE ''
END AS 允许空
,ISNULL(comm.text, '') AS 默认值
FROM dbo.syscolumns col
LEFT JOIN dbo.systypes t
ON col.xtype = t.xusertype
INNER JOIN dbo.sysobjects obj
ON col.id = obj.id
AND obj.xtype = 'U'
AND obj.status >=
LEFT JOIN dbo.syscomments comm
ON col.cdefault = comm.id
LEFT JOIN sys.extended_properties ep
ON col.id = ep.major_id
AND col.colid = ep.minor_id
AND ep.name = 'MS_Description'
LEFT JOIN sys.extended_properties epTwo
ON obj.id = epTwo.major_id
AND epTwo.minor_id =
AND epTwo.name = 'MS_Description'
WHERE obj.name = 'Ath_LoanApply_tbl'--表名
ORDER BY col.colorder;
IF (( SELECT
COUNT(*)
FROM fn_listextendedproperty('MS_Description',
'SCHEMA', N'dbo',
'TABLE', N'Fct_Order',
'COLUMN', N'Carrier'))
> ) EXEC sp_updateextendedproperty @name = N'MS_Description',
@value = N'承运商',
@level0type = 'SCHEMA',
@level0name = N'dbo',
@level1type = 'TABLE',
@level1name = N'Fct_Order',
@level2type = 'COLUMN',
@level2name = N'Carrier' ELSE EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'承运商',
@level0type = 'SCHEMA',
@level0name = N'dbo',
@level1type = 'TABLE',
@level1name = N'Fct_Order',
@level2type = 'COLUMN',
@level2name = N'Carrier'
GO
PrePackage_Header
IF NOT EXISTS ( SELECT NULL
FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'[PrePackage_Header]')
AND OBJECTPROPERTY(id, 'IsTable') = 1 )
BEGIN
CREATE TABLE PrePackage_Header
(
PrePackagedId [UNIQUEIDENTIFIER] NOT NULL ,
WarehouseId [UNIQUEIDENTIFIER] NOT NULL ,
PrePackagedCodeNumber [VARCHAR](50) NOT NULL ,
PrePackagedBarCodeNumber [VARCHAR](50) NOT NULL ,
PrePackagedName [VARCHAR](50) NOT NULL ,
Disabled INT
NOT NULL
CONSTRAINT [DF_PrePackage_Header_Disabled] DEFAULT ( (0) ) ,
Rec_CreateTime DATETIME
NULL
CONSTRAINT [DF_PrePackage_Header_Rec_CreateTime]
DEFAULT ( GETDATE() ) ,
Rec_CreateBy [VARCHAR](50) NULL ,
Rec_ModifyTime [DATETIME] NULL ,
Rec_ModifyBy [VARCHAR](50) NULL ,
CONSTRAINT [PK_PrePackage_Header] PRIMARY KEY CLUSTERED
( PrePackagedId ASC )
WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY]
)
ON [PRIMARY]; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装管理Id', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'PrePackagedId'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'仓库Id', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'WarehouseId'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装编码', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'PrePackagedCodeNumber'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装条码', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'PrePackagedBarCodeNumber'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装名称', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'PrePackagedName'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'是否禁用', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'Disabled'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'创建时间', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'Rec_CreateTime'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'创建人', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'Rec_CreateBy'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'修改时间', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'Rec_ModifyTime'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'修改人', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header',
@level2type = N'COLUMN', @level2name = N'Rec_ModifyBy'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装管理主表', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Header'; END;
GO PrePackage_Detail
IF NOT EXISTS ( SELECT NULL
FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'[PrePackage_Detail]')
AND OBJECTPROPERTY(id, 'IsTable') = 1 )
BEGIN
CREATE TABLE PrePackage_Detail
(
PrePackage_DetailId [UNIQUEIDENTIFIER] NOT NULL ,
PrePackagedId [UNIQUEIDENTIFIER] NOT NULL ,
GoodsId [UNIQUEIDENTIFIER] NULL ,
GoodsCode [VARCHAR](50) NULL ,
Qunatity DECIMAL(18, 2) NOT NULL ,
Disabled INT
NOT NULL
CONSTRAINT [DF_PrePackage_Detail_Disabled] DEFAULT ( (0) ) ,
Rec_CreateTime DATETIME
NULL
CONSTRAINT [DF_PrePackage_Detail_Rec_CreateTime]
DEFAULT ( GETDATE() ) ,
Rec_CreateBy [VARCHAR](50) NULL ,
Rec_ModifyTime [DATETIME] NULL ,
Rec_ModifyBy [VARCHAR](50) NULL ,
CONSTRAINT [PK_PrePackage_Detail] PRIMARY KEY CLUSTERED
( PrePackage_DetailId ASC )
WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY]
)
ON [PRIMARY]; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装明细Id', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'PrePackage_DetailId'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'货品编码', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'GoodsCode'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'货品Id', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'GoodsId'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'数量', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'Qunatity'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'是否删除', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'Disabled'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'创建时间', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'Rec_CreateTime'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'创建人', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'Rec_CreateBy'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'修改时间', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'Rec_ModifyTime'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'修改人', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail',
@level2type = N'COLUMN', @level2name = N'Rec_ModifyBy'; EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'预包装明细', @level0type = N'SCHEMA', @level0name = N'dbo',
@level1type = N'TABLE', @level1name = N'PrePackage_Detail'; END;
GO

获取、增加、修改、删除sqlserver字段描述的更多相关文章

  1. 获取、增加、修改、删除sqlserver字段描述及快速查看表字段与描述

    先看添加与删除字段描述 EXEC sys.sp_addextendedproperty @name = N'MS_Description', --添加Type字段说明 @value = N'屏蔽类型对 ...

  2. Oracle 增加修改删除字段

    Oracle 增加修改删除字段 添加字段的语法:alter table tablename add (column datatype [default value][null/not null],…. ...

  3. Oracle 增加修改删除字段与添加注释

    添加字段的语法:alter table tablename add (column datatype [default value][null/not null],….); 修改字段的语法:alter ...

  4. Oracle-表的字段增加修改删除操作

    表结构修改 ALTER TABLE SCOTT.TEST RENAME TO TEST1--修改表名 ALTER TABLE SCOTT.TEST RENAME COLUMN NAME TO NAME ...

  5. js jquery select 操作 获取值,选中选项,增加,修改,删除

    select示例: <select id="sel"> <option value="1">one</option> < ...

  6. 转 sqlserver字段描述相关操作sql

    可以自己查询系统表: SELECT o.name AS tableName, c.name AS columnName, p.[value] AS Description FROM sysproper ...

  7. sql 增加修改表格属性字段

    1.修改字段默认值 alter table 表名 drop constraint 约束名字 ------注解:删除表的字段的原有约束 alter table 表名 add constraint 约束名 ...

  8. hibernate 批量增加 修改 删除

    4.2  Hibernate的批量处理 Hibernate完全以面向对象的方式来操作数据库,当程序里以面向对象的方式操作持久化对象时,将被自动转换为对数据库的操作.例如调用Session的delete ...

  9. MySQL 字段常用操作 添加,修改,删除,调整字段顺序

    整理备忘: 添加字段:alter table 表名Add column 字段名 字段类型  默认值 AFTER 字段名 (在哪个字段后面添加) 例子: alter table appstore_sou ...

随机推荐

  1. 烂泥:kvm安装windows系统蓝屏

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近一直在学习有关KVM的知识,实验一直是在虚拟机VM中进行的.今天刚好公司有一台空闲的服务器,直接拿来安装centos.kvm等等,然后相关的配置. ...

  2. Linux 下从头再走 GTK+-3.0 (六)

    在 GTK3 中增加了一个 GtkApplicaton 类,便于我们处理多窗口程序,同时有了 GtkApplication 我们也更容易创建灵活,易用,界面美观的应用程序. 在前面的几个例子中,演示了 ...

  3. Android增加v7 appcompat源码

    1.File ---- Import---- Existing Android Code Into Workspace 2.选择 <sdk>/extras/android/support/ ...

  4. NOIP2008普及组 题解 -SilverN

    T1 ISBN号码 题目描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字.1位识别码和3位分隔符, 其规定格式如“x-xxx-xxxxx-x”,其中符号“-”就是分隔符( ...

  5. UVALive 6663 Count the Regions --离散化+DFS染色

    题意:给你n(n<=50)个矩形(左上角坐标和右下角坐标),问这些矩形总共将平面分成多少个部分.坐标值可能有1e9. 分析:看到n和坐标的范围,容易想到离散化,当时就没想到离散化以后怎么判断区域 ...

  6. 第23章 SEH结构化异常处理(1)_系统SEH机制

    23.1 基础知识 23.1.1 Windows下的软件异常 (1)中断和异常 ①中断是由外部硬件设备或异步事件产生的 ②异常是由内部事件产生的,可分为故障.陷阱和终止三类. (2)两种异常处理机制: ...

  7. uGUI练习(三) KeyBoard Navigation

    练习目标 练习通过键盘在按钮或其它Selectable类型组件上导航 步骤 创建一排的Button,及一个右边的Button 2.查看Button的属性里有一栏下拉列表Navigation,默认选择的 ...

  8. Android 三种动画详解

    [工匠若水 http://blog.csdn.net/yanbober 转载请注明出处.点我开始Android技术交流] 1 背景 不能只分析源码呀,分析的同时也要整理归纳基础知识,刚好有人微博私信让 ...

  9. GitHub入门之二 参与一个项目编写

    接上文:大多数时候我们也需要把别人的代码进行整合和修改,而不是简单的修改,这时就需要对一个项目进行修改. 注意,本系列文章主要说明在github网站上的操作,更多高级操作请使用git控制台 一.for ...

  10. Silverlight 利用DataGrid行加载事件动态控制行列显示

    datagrid的绑定很好用,但有时候我们往往需要根据model内容来动态控制行或者列,该怎么办呢? 这时候,我们就需要用到行加载事件:在加载每一行数据的时候,根据数据的内容来控制相应的表格显示. 比 ...