本文转载自:http://www.cnblogs.com/zhangxb/archive/2012/04/20/2458898.html

1. 列注释

原来代码:

{OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOMAIN, DEFAULT, ExtIdentitySeedInc, COMMENT, ExtCollation, ExtIdtNotForReplication, ExtDeftConstName, Sparse, FileStream, ExtRowGuidCol}

select
    u.name,
    o.name,
    c.column_id,
    c.name,
    case when c.system_type_id in (165, 167, 231) and c.max_length = -1 then t.name + '(Max)' else t.name end,
    c.precision,
    case (c.max_length) when -1 then 0 else case when c.system_type_id in (99, 231, 239) then (c.max_length/2) else (c.max_length) end end as colnA,
    c.scale,
    case(c.is_computed) when 1 then convert(varchar(8000), (select z.definition from [%CATALOG%.]sys.computed_columns z where z.object_id = c.object_id and z.column_id = c.column_id)) else '' end as colnB,
    case(c.is_nullable) when 1 then 'NULL' else 'NOTNULL' end,
    case(c.is_identity) when 1 then 'identity' else '' end,
    case when(c.user_type_id <> c.system_type_id) then (select d.name from [%CATALOG%.]sys.types d where d.user_type_id = c.user_type_id) else '' end as colnC,
    convert(varchar(8000), d.definition),
    case (c.is_identity) when 1 then convert(varchar, i.seed_value) + ', ' + convert(varchar, i.increment_value) else '' end as colnD,
    (select convert(varchar(8000), value) from ::fn_listextendedproperty(NULL, 'user', u.name, 'table', o.name, 'column', c.name) where name = 'MS_Description') as colnE,
    c.collation_name,
    case (i.is_not_for_replication) when 1 then 'true' else 'false' end,
    d.name,
    case(c.is_sparse) when 1 then 'true' else 'false' end,
    case(c.is_filestream) when 1 then 'true' else 'false' end,
    case(c.is_rowguidcol) when 1 then 'true' else 'false' end
from
    [%CATALOG%.]sys.columns      c
    join [%CATALOG%.]sys.objects o on (o.object_id = c.object_id)
    join [%CATALOG%.]sys.schemas u on (u.schema_id = o.schema_id)
    join [%CATALOG%.]sys.types   t on (t.user_type_id = c.system_type_id)
    left outer join [%CATALOG%.]sys.identity_columns i on (i.object_id = c.object_id and i.column_id = c.column_id)
    left outer join [%CATALOG%.]sys.default_constraints d on (d.object_id = c.default_object_id)

where
   o.type in ('U', 'S', 'V')
[  and u.name = %.q:OWNER%]
[  and o.name=%.q:TABLE%]
order by 1, 2, 3

解决方案:

在PD的 tools-->resources-->dbms-->sql server 2008打开DBMS属性窗口,在general选项卡中选择Microsoft SQL Server 2008-->script-->objects-->column-->SQLlistquery修改其中的内容为:

{OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOMAIN, DEFAULT, ExtIdentitySeedInc, COMMENT, ExtCollation, ExtIdtNotForReplication, ExtDeftConstName, Sparse, FileStream, ExtRowGuidCol}

select
    u.name,
    o.name,
    c.column_id,
    c.name,
    case when c.system_type_id in (165, 167, 231) and c.max_length = -1 then t.name + '(Max)' else t.name end,
    c.precision,
    case (c.max_length) when -1 then 0 else case when c.system_type_id in (99, 231, 239) then (c.max_length/2) else (c.max_length) end end as colnA,
    c.scale,
    case(c.is_computed) when 1 then convert(varchar(8000), (select z.definition from [%CATALOG%.]sys.computed_columns z where z.object_id = c.object_id and z.column_id = c.column_id)) else '' end as colnB,
    case(c.is_nullable) when 1 then 'NULL' else 'NOTNULL' end,
    case(c.is_identity) when 1 then 'identity' else '' end,
    case when(c.user_type_id <> c.system_type_id) then (select d.name from [%CATALOG%.]sys.types d where d.user_type_id = c.user_type_id) else '' end as colnC,
    convert(varchar(8000), d.definition),
    case (c.is_identity) when 1 then convert(varchar, i.seed_value) + ', ' + convert(varchar, i.increment_value) else '' end as colnD,
    convert(varchar(8000),e.value),
    c.collation_name,
    case (i.is_not_for_replication) when 1 then 'true' else 'false' end,
    d.name,
    case(c.is_sparse) when 1 then 'true' else 'false' end,
    case(c.is_filestream) when 1 then 'true' else 'false' end,
    case(c.is_rowguidcol) when 1 then 'true' else 'false' end
from
    [%CATALOG%.]sys.columns      c
    join [%CATALOG%.]sys.objects o on (o.object_id = c.object_id)
    join [%CATALOG%.]sys.schemas u on (u.schema_id = o.schema_id)
    join [%CATALOG%.]sys.types   t on (t.user_type_id = c.system_type_id)
    left outer join [%CATALOG%.]sys.identity_columns i on (i.object_id = c.object_id and i.column_id = c.column_id)
    left outer join [%CATALOG%.]sys.default_constraints d on (d.object_id = c.default_object_id)
    left outer join [%CATALOG%.]sys.extended_properties e on (e.class=u.schema_id and e.major_id=o.object_id and e.minor_id = c.column_id and e.name=N'MS_Description')
where
   o.type in ('U', 'S', 'V')
[  and u.name = %.q:OWNER%]
[  and o.name=%.q:TABLE%]
order by 1, 2, 3

2. 表注释

原为:

{OWNER, TABLE, TABLE_TYPE, COMMENT}

select
   u.name,
   o.name,
   case (o.type) when 'S' then 'SYSTEM TABLE' else 'TABLE' end,
   (select convert(varchar(8000), value) from ::fn_listextendedproperty(NULL, 'user', u.name, 'table', o.name, null, null) where name = 'MS_Description') as coln
from
   [%CATALOG%.]sys.sysobjects o
   join [%CATALOG%.]sys.schemas  u on (u.schema_id = o.uid)
where
   o.type in ('U', 'S')
[  and u.name = %.q:OWNER%]
order by 1, 2

解决办法:

在PD的 tools-->resources-->dbms-->sql server 2008打开DBMS属性窗口,在general选项卡中选择Microsoft SQL Server 2008-->script-->objects-->Table-->SQLlistquery修改其中的内容为:

{OWNER, TABLE, TABLE_TYPE, COMMENT}

select
   u.name,
   o.name,
   case (o.type) when 'S' then 'SYSTEM TABLE' else 'TABLE' end
   ,convert(varchar(8000), e.value) as coln
from
   [%CATALOG%.]sys.sysobjects o
   join [%CATALOG%.]sys.schemas  u on (u.schema_id = o.uid)
   left join [%CATALOG%.]sys.extended_properties e on (e.class=u.schema_id and e.major_id=o.id and e.minor_id=0 and e.name=N'MS_Description')
where
   o.type in ('U', 'S')
[  and u.name = %.q:OWNER%]
order by 1, 2

3. 反向工程后,在Users中删除dbo用户,然后生成脚本即可运行。

解决PowerDesigner 反向工程没有注释(备注)的更多相关文章

  1. 解决PowerDesigner 反向工程没有注释(备注)

    1. 列注释 原来代码: {OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOM ...

  2. powerdesigner 字段添加注释和默认值

    powerdesigner 字段添加注释和默认值 2017年01月06日 10:59:02 qingzhuoran 阅读数:27161更多 个人分类: powerdesigner   1.选中表,右键 ...

  3. Eclipse+pydev解决中文显示和注释问题的方法大全

    Eclipse+pydev解决中文显示和注释问题的方法大全 Eclipse的设置 window->preferences->general->editors->textedit ...

  4. PowerDesigner列名、注释内容互换

    资料来源:PowerDesigner列名.注释内容互换 文中一共提供了2种操作的代码. (1)将Name中的字符COPY至Comment中 (2)将Comment中的字符COPY至Name中 使用方法 ...

  5. 解决PowerDesigner提示This data item is already used in a primary identifier

    解决PowerDesigner提示This data item is already used in a primary identifier 解决PowerDesigner提示This data i ...

  6. PowerDesigner 15进行逆向工程生成数据库图表时,注释的comment的生成,解决PowerDesigner逆向工程没有列注释

    使用PowerDesigner默认配置逆向工程是没有注释(name列为英文,comment列是空的),这样的不方便查看字段具体是什么意义,将注释一同导出,方便查看字段具体的意义,如下图 注释列导出步骤 ...

  7. PowerDesigner反向工程PostgreSQL数据库

    1. 环境准备: a)         安装PowerDesigner,以PowerDesigner15.1为例 b)         安装java jdk,以jdk-7-windows-i586为例 ...

  8. 解决PowerDesigner 生成Sql2005-2012 找不到sysproperties表的问题

    造成此问题的原因是由于Sql 2005 删除了系统表 sysproperties 而改用 sys.extended_properties 表所致 ,微软的目的不再去猜测网上有二种解决方式 但不符合本人 ...

  9. C# .NET 获取枚举值的自定义属性(特性/注释/备注)信息

    一.引言 枚举为我看日常开发的可读性提供的非常好的支持,但是有时我们需要得到枚举值得描述信息或者是注释(备注)信息 比如要获得 TestEmun.aaa 属性值得备注 AAA,比较不方便得到. pub ...

随机推荐

  1. SQL注入中利用XP_cmdshell提权的用法(转)

    先来介绍一下子服务器的基本情况,windows 2000 adv server 中文版,据称 打过了sp3,asp+iis+mssql .首先扫描了一下子端口,呵呵,开始的一般步骤. 端口21开放: ...

  2. (转)我是如何在SQLServer中处理每天四亿三千万记录的

    首先声明,我只是个程序员,不是专业的DBA,以下这篇文章是从一个问题的解决过程去写的,而不是一开始就给大家一个正确的结果,如果文中有不对的地方,请各位数据库大牛给予指正,以便我能够更好的处理此次业务. ...

  3. mvc JavaScriptResult的用法

    一.JavaScriptResult在MVC中的定义的代码片段   C# 代码   复制 public class JavaScriptResult : ActionResult { public o ...

  4. Python 笔记 : 类和继承

    # -*- coding=  utf-8 -*- # 文件编码定义的语法规则是: coding[:=]/s*([-/w.]+) # 未指定编码将默认为 : ASCII # 同时要注意物理文件的编码也要 ...

  5. ACM1996

    /* 汉诺塔VI Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  6. 第二百八十六天 how can I 坚持

    bug不断啊,头疼. 今天早上到的倒是挺早. 中午吃的黄焖鸡,晚上加了会班. 勇江的鱼都死了,杨建的还剩3条,晚上到家都快十点了,还洗了衣服,没捞出来呢, 希望可以请下来假吧. 晾上衣服睡觉.

  7. RTT操作系统

    http://www.rt-thread.org/官网 RT-Thread RTOS,由国内一些专业开发人员开发.维护.它不仅仅是一款 高效.稳定的实时操作系统内核,也是一套面向嵌入式系统的软件平台, ...

  8. uva10474 简单排序查找 一次AC

    题目很简单,加上读题20分钟一次AC.还是用到了快排qsort. #include<iostream> #include<cstdlib> using namespace st ...

  9. HDU 4463 Outlets (最小生成树)

    题意:给定n个点坐标,并且两个点已经连接,但是其他的都没有连接,但是要找出一条最短的路走过所有的点,并且路线最短. 析:这个想仔细想想,就是应该是最小生成树,把所有两点都可以连接的当作边,然后按最小生 ...

  10. PHP 中运用 elasticsearch

    PHP扩展安装 1. 环境要求:PHP_VERSION >= 5.3.9,composer工具 2. 在E盘新建文件夹命名为elastic,,拷贝composer.phar到      E:/e ...