zoukankan      html  css  js  c++  java
  • 解决PowerDesigner 16 Generate Datebase For Sql2005/2008 对象名sysproperties无效的问题

    在PowerDesigner 16 中生成的sql语句,在执行的时候报错:对象名sysproperties 无效的错误;造成此问题的原因是由于Sql 2005、2008 删除了系统表 sysproperties 而改用 sys.extended_properties 表所致 , 以下是通过创建sysproperties视图,以及修改powerdesigner sql语句生成模板后,

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


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


     if exists (select 1 from sysobjects where name = 'sysproperties'and 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%

    ]

  • 相关阅读:
    hdwiki 学习笔记 01
    hdwiki model目录下的函数类
    hdwiki 的模板和标签
    Linux下CPU内存占用过高思路分析
    Linux下后台运行jar包
    Arrays.asList集合类的集合转换方法的坑!!!(不支持的操作异常:UnsupportedOperationException)
    Linux下定时备份mysql数据库
    解决Navicat远程连接数据库出现错误:1130-host ... is not allowed to connect to this MySql server
    深入JVM学习
    JUC的等待唤醒机制(wait/notify await/singal)之生产者和消费者问题
  • 原文地址:https://www.cnblogs.com/mtsl/p/4232451.html
Copyright © 2011-2022 走看看