根据网上查询到的资料,找到了解决方法,原文出自:http://www.cnblogs.com/24tt/p/5047257.html
PowerDesign 16.0 生成的Script语句,Sql2000内,带字段备注的语句执行时存在如下错误:
PowerDesigner 无法更新或删除属性。“某某”的属性 MS_Description不存在。
MSSQLSRV2000::Script\Objects\Column\ColumnComment
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%
]
该代码经过测试,暂时没问题。
这是修改位置