视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
解决方案:PowerDesigner16生成的SqlServer2000/2005/2008脚本执行出现:“对象名
2020-11-09 10:09:23 责编:小采
文档


现象: 在PowerDesigner 16 中生成的sql语句,在执行的时候报错: 对象名sysproperties 无效的错误 ; 原因分析: 造成此问题的原因是由于Sql 2005、2008 删除了系统表 sysproperties 而改用 sys.extended_properties 表所致 , 以下是通过创建sysproperties视

现象:

在PowerDesigner 16 中生成的sql语句,在执行的时候报错:对象名sysproperties 无效的错误;

原因分析:

造成此问题的原因是由于Sql 2005、2008 删除了系统表 sysproperties 而改用 sys.extended_properties 表所致 , 以下是通过创建sysproperties视图,以及修改powerdesigner sql语句生成模板后,再生成数据库SQL脚本执行,共分为三部:

第一步:

在Sql 2005/2008/2012查询分析器中执行下面的 Sql 语句创建View 'sysproperties'

sysobjects xtype ) sysproperties 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)

第二 步:

修改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%) and minor_id = 0 and name = 'MS_Description') begin [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]], [%R%?[N]]%.q:TABLE% :declare @CurrentUser sysname select @CurrentUser = user_name() [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]], [%R%?[N]]%.q:TABLE% ] end ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]], [%R%?[N]]%.q:TABLE% :select @CurrentUser = user_name() [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]], [%R%?[N]]%.q:TABLE% ]

第三步:

修改Column ColumnComment模板 路径是 Database -> Edit Current DBMS 窗体 General 选项卡 下 Script -> Objects -> Column -> ColumnComment

[if exists (select 1 from sysproperties where TableID = object_id('[%QUALIFIER%) and ColName = %.q:COLUMN% AND PropName='MS_Description') begin [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]], [%R%?[N]]%.q:COLUMN% :declare @CurrentUser sysname select @CurrentUser = user_name() [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]], [%R%?[N]]%.q:COLUMN% ] end ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]], [%R%?[N]]%.q:COLUMN% :select @CurrentUser = user_name() [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]], [%R%?[N]]%.q:COLUMN% ]

修改之后 使用Generate Database 生成的SQL便可在SQL 2005/2008下执行 不在报找不到sysproperties 的错误。

大功告成!!!

作者:记忆逝去的青春 出处: 本文版权归作者和博客园共有,空间,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,如有问题,美国空间,可以通过 联系我,非常感谢。

  

,服务器空间

下载本文
显示全文
专题