PowerDesigner16建表在SQL SERVER 2008报 对象名 'sysproperties' 无效。

     sysproperties 对象是是以前老版本的sql server的对象,在2005以后就删掉了此对象,改为  sys.extended_properties,所以,需要调整 PowerDesigner 生成的建表语句的模版
   
    首先,TableComment 模版数据,修改在PowerDesigner 下进入 Database -> Edit Current DBMS -> General -> Script -> Objects -> Table -> TableComment 目录
   下面是源生成建表的模版数据
  1. [if exists (select 1
  2. from sysproperties
  3. where id = object_id('[%QUALIFIER%]%TABLE%')
  4. and type = 3)
  5. begin
  6. [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  7. [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  8. :declare @CurrentUser sysname
  9. select @CurrentUser = user_name()
  10. [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  11. [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  12. ]
  13. end
  14. ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  15. [%R%?[N]]%.q:COMMENT%,
  16. [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  17. :select @CurrentUser = user_name()
  18. [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  19. [%R%?[N]]%.q:COMMENT%,
  20. [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  21. ]
下面是新的内容(红色部分即为调整的内容)
  1. [if exists (select 1
  2.             from sys.extended_properties
  3.            where major_id = object_id('[%QUALIFIER%]%TABLE%')
  4.             and minor_id = 0 and name = 'MS_Description')
  5. begin
  6.    [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  7.    [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  8. :declare @CurrentUser sysname
  9. select @CurrentUser = user_name()
  10. [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  11.    [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  12. ]
  13. end


  14. ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  15.    [%R%?[N]]%.q:COMMENT%,
  16.    [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  17. :select @CurrentUser = user_name()
  18. [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  19.    [%R%?[N]]%.q:COMMENT%,
  20.    [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%
  21. ]

其次,更改 ColumnComment,  修改在 PowerDesigner 下进入  Database -> Edit Current DBMS -> General -> Script -> Objects -> Column -> ColumnComment 目录
  1. [if exists (select 1
  2.             from sysproperties
  3.            where id = object_id('[%QUALIFIER%]%TABLE%')
  4.             and type = 4)
  5. begin
  6.    [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  7.    [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  8. :declare @CurrentUser sysname
  9. select @CurrentUser = user_name()
  10. [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]\'MS_Description\',
  11.    [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  12. ]

  13. end


  14. ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  15.    [%R%?[N]]%.q:COMMENT%,
  16.    [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  17. :select @CurrentUser = user_name()
  18. [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  19.    [%R%?[N]]%.q:COMMENT%,
  20.    [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  21. ]
下面是新的内容 (红色部分即为调整的内容
  1. [if exists (select 1
  2.             from sys.extended_properties
  3.            where major_id = object_id('[%QUALIFIER%]%TABLE%')
  4.             and value = [%R%?[N]]%.q:COMMENT%)
  5. begin
  6.    [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  7.    [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  8. :declare @CurrentUser sysname
  9. select @CurrentUser = user_name()
  10. [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description',
  11.    [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  12. ]

  13. end


  14. ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  15.    [%R%?[N]]%.q:COMMENT%,
  16.    [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  17. :select @CurrentUser = user_name()
  18. [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description',
  19.    [%R%?[N]]%.q:COMMENT%,
  20.    [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN%
  21. ]
修改完成后,再打开建表的语句,就编程新的模版信息了。







    

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30150152/viewspace-1454979/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30150152/viewspace-1454979/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值