当前位置:Gxlcms > 数据库问题 > 解决PowerDesigner 16 Generate Datebase For Sql2005/2008 对象名sysproperties无效的问题

解决PowerDesigner 16 Generate Datebase For Sql2005/2008 对象名sysproperties无效的问题

时间:2021-07-01 10:21:17 帮助过:15人阅读

再生成数据库SQL脚本执行,共分为三部:

第一步:在Sql 2005/2008 Exec the Sql 创建View ‘sysproperties‘

if exists (select 1 from sysobjects where name = syspropertiesand xtype = V)
begin
    DROP VIEW sysproperties
end
    GO
    CREATE VIEW sysproperties
    AS
    SELECT A.name As TableName,
    A.id As TableID,B.Name As ColName,B.colid As ColID,
    B.xtype As ColType,C.name As PropName,C.Value As PropValue
    FROM sysobjects As A INNER JOIN syscolumns As B ON A.id = B.id
    INNER JOIN sys.extended_properties As C ON C.major_id = A.id 
    AND ( minor_id = B.colid)

第二 步: 修改Table TableComment模板 路径是 Database -> Edit Current DBMS 窗体 General 选项卡 下 Script -> Objects -> Table -> TableComment

[if exists (select 1 
from sys.extended_properties 
where major_id = object_id(‘[%QUALIFIER%]%TABLE%) 
and minor_id = 0 and name = MS_Description) 
begin 
[%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]MS_Description, 
[%R%?[N]]user, [%R%?[N]]%.q:OWNER%, [%R%?[N]]table, [%R%?[N]]%.q:TABLE% 
:declare @CurrentUser sysname 
select @CurrentUser = user_name() 
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]MS_Description, 
[%R%?[N]]user, [%R%?[N]]@CurrentUser, [%R%?[N]]table, [%R%?[N]]%.q:TABLE% 
] 
end 

][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]MS_Description, 
[%R%?[N]]%.q:COMMENT%, 
[%R%?[N]]user, [%R%?[N]]%.q:OWNER%, [%R%?[N]]table, [%R%?[N]]%.q:TABLE% 
:select @CurrentUser = user_name() 
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]MS_Description, 
[%R%?[N]]%.q:COMMENT%, 
[%R%?[N]]user, [%R%?[N]]@CurrentUser, [%R%?[N]]table, [%R%?[N]]%.q:TABLE% 
]

第三步:修改Column ColumnComment模板 路径是 Database -> Edit Current DBMS 窗体 General 选项卡 下 Script -> Objects -> Column -> ColumnComment

[if exists (select 1
from sysproperties
where TableID = object_id(‘[%QUALIFIER%]%TABLE%)
and ColName = %.q:COLUMN% AND PropName=MS_Description)
begin
[%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]MS_Description,
[%R%?[N]]user, [%R%?[N]]%.q:OWNER%, [%R%?[N]]table, [%R%?[N]]%.q:TABLE%, [%R%?[N]]column, [%R%?[N]]%.q:COLUMN%
:declare @CurrentUser sysname
select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]MS_Description, 
[%R%?[N]]user, [%R%?[N]]@CurrentUser, [%R%?[N]]table, [%R%?[N]]%.q:TABLE%, [%R%?[N]]column, [%R%?[N]]%.q:COLUMN%
]

end

][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]MS_Description,
[%R%?[N]]%.q:COMMENT%,
[%R%?[N]]user, [%R%?[N]]%.q:OWNER%, [%R%?[N]]table, [%R%?[N]]%.q:TABLE%, [%R%?[N]]column, [%R%?[N]]%.q:COLUMN%
:select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]MS_Description, 
[%R%?[N]]%.q:COMMENT%,
[%R%?[N]]user, [%R%?[N]]@CurrentUser, [%R%?[N]]table, [%R%?[N]]%.q:TABLE%, [%R%?[N]]column, [%R%?[N]]%.q:COLUMN%
]

修改之后 使用Generate Database 生成的SQL便可在SQL 2005/2008下执行 不在报找不到sysproperties 的错误。

本文复制来自:http://www.cnblogs.com/zhouchaoyi/archive/2012/03/07/2383509.html

解决PowerDesigner 16 Generate Datebase For Sql2005/2008 对象名sysproperties无效的问题

标签:Owner   table   ase   com   weight   对象   des   选项卡   pex   

人气教程排行