PD16 Generate Datebase For Sql2008R2時報腳本錯誤“對象名sysproperties無效”


PowerDesinger16創建數據庫表到SQL2008R2時,執行報“對象名sysproperties無效”錯誤。

主要是在建模時我們對表、列增加了些說明注釋,而Sql2005之后系統表sysproperties已廢棄刪除而改用sys.extended_properties所致。

此問題解決主要參考了http://hi.baidu.com/xuefliang/item/45e7f71421d5a67871d5e8e2

 

1、修改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 ) 
/* SQL2008 屬性表sysproperties改為 sys.extended_properties代替,替換以下腳本
[if exists (select 1 
            from  sysproperties 
           where  id = object_id('[%QUALIFIER%]%TABLE%') 
            and   type = 3) 
*/

 

2、修改Column ColumnComment模板

路徑是 Database -> Edit Current DBMS 窗體 General 選項卡 下 Script -> Objects -> Column –> ColumnComment

[if exists (select 1
            from  sys.extended_properties
            where  major_id = object_id('[%QUALIFIER%]%TABLE%') 
            and   minor_id <> 0 and name = 'MS_Description') 
/* SQL2008 屬性表sysproperties改為 sys.extended_properties代替,替換以下腳本
if exists (select 1
            from  sysproperties
           where  id = object_id('[%QUALIFIER%]%TABLE%')
            and   type = 4)
*/

也可創建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)  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM