根據網上查詢到的資料,找到了解決方法,原文出自: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% ]
該代碼經過測試,暫時沒問題。
這是修改位置
