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%
    ]

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

    这是修改位置

  • 相关阅读:
    Unity 3(一):简介与示例
    MongoDB以Windows Service运行
    动态SQL中变量赋值
    网站发布IIS后堆栈追踪无法获取出错的行号
    GridView Postback后出错Operation is not valid due to the current state of the object.
    Visual Studio 2010 SP1 在线安装后,找到缓存在本地的临时文件以便下次离线安装
    SQL Server 问题之 排序规则(collation)冲突
    IIS 问题集锦
    linux下安装mysql(ubuntu0.16.04.1)
    apt-get update 系列作用
  • 原文地址:https://www.cnblogs.com/kfarvid/p/6265658.html
Copyright © 2011-2022 走看看