zoukankan      html  css  js  c++  java
  • PowerDesign 16.0 生成的SQL Server2000 数据库脚本时MS_Description不存在的问题解决

    根据网上查询到的资料,找到了解决方法,原文出自:http://www.cnblogs.com/24tt/p/5047257.html

    PowerDesign 16.0 生成的Script语句,Sql2000内,带字段备注的语句执行时存在如下错误:

    PowerDesigner 无法更新或删除属性。“某某”的属性 MS_Description不存在。

     MSSQLSRV2000::ScriptObjectsColumnColumnComment

    Modified Column ColComment  

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

    实际上是默认生成语句存在判断错误:默认的如下():

    [if exists (select 1 from sysproperties where id = object_id('[%QUALIFIER%]%TABLE%')  and type = 4) begin

    以上判断是该表是否已存在备注,当有2个及以上备注要添加时(如C1,C2),添加到第二个备注C2,判断系统一定存在,而紧接着需要执行删除C2,因C2都没有添加过需要删除肯定会提示“无法更新或删除属性”了。sp_dropextendedproperty 

    因此需要修改判断,定位到精准的该字段是否有备注,有则删除,修改为如下(红色为添加部分,SQL2000测试通过):

    [if exists (select 1

                from  sysproperties            where  id = object_id('[%QUALIFIER%]%TABLE%') and smallid in(select colid from syscolumns where id = object_id('[%QUALIFIER%]%TABLE%') and name = %.q:COLUMN%  and number = 0) and name='MS_Description'  and type = 4 ) begin

    最后贴出完整的代码:

    [if exists (select 1
    from sysproperties
    where id = object_id('[%QUALIFIER%]%TABLE%')
    and smallid in(select colid
    from    syscolumns
    where    id = object_id('[%QUALIFIER%]%TABLE%')
    and name = %.q:COLUMN% and
    number = 0) and name='MS_Description'  and type = 4 )
    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%
    ]

    该代码经过测试,暂时没问题。

    这是修改位置

  • 相关阅读:
    A1023 Have Fun with Numbers (20分)(大整数四则运算)
    A1096 Consecutive Factors (20分)(质数分解)
    A1078 Hashing (25分)(哈希表、平方探测法)
    A1015 Reversible Primes (20分)(素数判断,进制转换)
    A1081 Rational Sum (20分)
    A1088 Rational Arithmetic (20分)
    A1049 Counting Ones (30分)
    A1008 Elevator (20分)
    A1059 Prime Factors (25分)
    A1155 Heap Paths (30分)
  • 原文地址:https://www.cnblogs.com/kfarvid/p/6265658.html
Copyright © 2011-2022 走看看