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)  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值