先看添加与删除字段描述

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. 形如(function(){}).call()的js语句

    研究新浪微博的自动登陆流程,其中涉及到它的加密算法脚本,其中有一段如下形式的代码: (function(){...}).call(name) 其中红色的....是函数的内部各种实现,name为一个对象 ...

  2. HADOOP namenode HA

    参考的文章:http://www.cnblogs.com/smartloli/p/4298430.html 当然,在操作的过程中,发现与上述文章中描述的还是有一些小小的区别. 配置好后,start-d ...

  3. quick sort java version

    import java.util.Random; public class test { public static void main(String[] args) { int[] arr= gen ...

  4. 集成TFS Build生成与SonarQube获取代码分析结果

    软件项目在开发过程中,往往由于任务重.时间紧等原因忽略软件代码的质量和规范检查,只注重软件功能的开发和交付.等软件交付上线以后,由于代码质量导致的问题会耗费开发和运维人员的大量时间.研发表明,项目上线 ...

  5. 一道题看bitset应用 --ZOJ 3642

    题意:给n个文件,包括文件名和文件大小,然后给出k个关键词,查询包含该关键词的文件的大小总和.文件名为一些中括号括起的关键词的合集. 解法:可用bitset记录每一个关键词在哪些文件中出现,然后查询即 ...

  6. POJ 1442 Black Box -优先队列

    优先队列..刚开始用蠢办法,经过一个vector容器中转,这么一来一回这么多趟,肯定超时啊. 超时代码如下: #include <iostream> #include <cstdio ...

  7. [AS3] 问个很囧的问题: 如何遍历Dictionary?

    可以使用 for...in 循环或 for each...in 循环来遍历 Dictionary 对象的内容. for...in 循环用于基于键进行遍历: 而 for each...in   循环用于 ...

  8. java 15 - 8 集合框架(并发修改异常的产生原因以及解决方案)

    问题?   我有一个集合,如下,请问,我想判断里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素,请写代码实现.  面试题: Concu ...

  9. Saltstack-自动化部署

    Saltstack概述 Salt一种全新的基础设施管理方式,部署轻松,在几分钟内可运行起来,扩展性好,很容易管理上万台服务器,速度够快,服务器之间秒级通讯. salt底层采用动态的连接总线, 使其可以 ...

  10. 【转】【WPF】wpf 图片指针处理

    我一直用GDI+做Winform 的基于指针的图片处理,这次下决心全部移到wpf上(主要是显示布局很方便)采用的图片是2512*3307 的大图 830万像素类库基于WritableBitmapEx ...