PowerDesinger16建立數據庫表到SQL2008R2時,執行報「對象名sysproperties無效」錯誤。數據庫
主要是在建模時咱們對錶、列增長了些說明註釋,而Sql2005以後系統表sysproperties已廢棄刪除而改用sys.extended_properties所致。spa
此問題解決主要參考了http://hi.baidu.com/xuefliang/item/45e7f71421d5a67871d5e8e2,code
一、修改Table TableComment模板對象
路徑是 Database -> Edit Current DBMS 窗體 General 選項卡 下 Script -> Objects -> Table –> TableCommentip
[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) */
二、修改Column ColumnComment模板get
路徑是 Database -> Edit Current DBMS 窗體 General 選項卡 下 Script -> Objects -> Column –> ColumnCommentit
[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視圖來,經過此視圖處理以上問題。io
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)