程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> SqlServer2005 >> PowerDesigner16生成SQL2005列注釋的方法

PowerDesigner16生成SQL2005列注釋的方法

編輯:SqlServer2005

Powerdesigner界面-tools-Resources-DBMS,點擊左上角的New,選擇copy from templete,如果你的數據庫是sql server 2005,選擇系統自帶的SQL server 2005,如果是sql server 2008,選擇系統自帶的sqlsv2k8.xdb。

如果你想修改默認的選項,可以直接選擇SQL server 2005或者08.

選擇Script---Objects---Column---SqlListQuery

修改為如下的代碼:

復制代碼 代碼如下:
{OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOMAIN, DEFAULT, ExtIdentitySeedInc, COMMENT,COLNNAME, ExtCollation, ExtIdtNotForReplication, ExtDeftConstName, 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), p.value),
    convert(varchar(8000), p.value),
    c.collation_name,
    case (i.is_not_for_replication) when 1 then 'true' else 'false' end,
    d.name,
    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 p on (p.major_id = o.object_id and p.minor_id = c.column_id and p.class =1)
where
   o.type in ('U', 'S', 'V')

[  and u.name = %.q:OWNER%]
[  and o.name=%.q:TABLE%]
order by 1, 2, 3

其實只是增加了上面代碼中的黃色部分,就可以了。測試後,ok。
其實我還想修改表注釋,就是在顯示英文表名的地方顯示出中文含義,如acccount(賬戶表)
但是修改了table中的很多地方都沒有成功,不知道大家有沒有知道如何修改的,如果知曉請告知。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved