当前位置:Gxlcms > 数据库问题 > PowerDesigner 16.5对SQL Server 2012 生成数据库时"不支持扩展属性"问题

PowerDesigner 16.5对SQL Server 2012 生成数据库时"不支持扩展属性"问题

时间:2021-07-01 10:21:17 帮助过:12人阅读

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id(Environment.Resource)
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = ResourceCode)
)
begin
   execute sp_dropextendedproperty MS_Description,
   user, Environment, table, Resource, column, ResourceCode

end
execute sp_addextendedproperty MS_Description,
   资源编码,
   user, Environment, table, Resource, column, ResourceCode
go
技术分享

分析原因,发现是由于采用了Schema(上述代码中的Environment),所以sp_addextendedproperty存储过程的第三个参数就应该是SCHEMA而不是user。查询相关资料发现以上SQL语句是基于Powerdesigner自带的对应的.xdb文件生成的,如下图是Column注释信息的SQL代码模板,对应的xdb模板文件存放在powerdesigner安装路径的Sybase\PowerDesigner 16\Resource Files\DBMS\sqlsv2012.xdb

技术分享

如上图,每个Column的Comment信息均通过以上代码模板生成,所以只需要修改代码模板(将sp_addextendedproperty的第三个参数值由user修改为schema即可)即可让所有对象的Comment生成语句得到修正。

注:在win7以上系统中需要使用管理员权限运行powerdesigner才能将修改后的模板文件保存。

 

摘自:http://www.cnblogs.com/xqyi/p/3937769.html

 

补充:

技术分享

 

ColumnContent修改为:

技术分享

 

Value修改为:

[if exists (select 1 from  sys.extended_properties
           where major_id = object_id(‘[%QUALIFIER%]%TABLE%‘) and minor_id = 0)
begin 
   [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]‘MS_Description‘,  
   [%R%?[N]]‘schema‘, [%R%?[N]]%.q:OWNER%, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE% 
:declare @CurrentUser sysname 
select @CurrentUser = SCHEMA_NAME() 
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]‘MS_Description‘,  
   [%R%?[N]]‘schema‘, [%R%?[N]]@CurrentUser, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE% 
] 
end 


][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]‘MS_Description‘,  
   [%R%?[N]]%.q:COMMENT%, 
   [%R%?[N]]‘schema‘, [%R%?[N]]%.q:OWNER%, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE% 
:select @CurrentUser = SCHEMA_NAME()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]‘MS_Description‘,  
   [%R%?[N]]%.q:COMMENT%, 
   [%R%?[N]]‘schema‘, [%R%?[N]]@CurrentUser, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE% 
]

技术分享

Values修改为:

[if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id(‘[%QUALIFIER%]%TABLE%‘)
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = %.q:COLUMN%)
)
begin
   [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]‘MS_Description‘, 
   [%R%?[N]]‘schema‘, [%R%?[N]]%.q:OWNER%, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE%, [%R%?[N]]‘column‘, [%R%?[N]]%.q:COLUMN%
:declare @CurrentUser sysname
select @CurrentUser = SCHEMA_NAME()
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]‘MS_Description‘, 
   [%R%?[N]]‘schema‘, [%R%?[N]]@CurrentUser, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE%, [%R%?[N]]‘column‘, [%R%?[N]]%.q:COLUMN%
]
end


][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]‘MS_Description‘, 
   [%R%?[N]]%.q:COMMENT%,
   [%R%?[N]]‘schema‘, [%R%?[N]]%.q:OWNER%, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE%, [%R%?[N]]‘column‘, [%R%?[N]]%.q:COLUMN%
:select @CurrentUser = SCHEMA_NAME()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]‘MS_Description‘, 
   [%R%?[N]]%.q:COMMENT%,
   [%R%?[N]]‘schema‘, [%R%?[N]]@CurrentUser, [%R%?[N]]‘table‘, [%R%?[N]]%.q:TABLE%, [%R%?[N]]‘column‘, [%R%?[N]]%.q:COLUMN%
]

这个是表的

其他类型同理,主要修改Values值中的user为schema,和select @CurrentUser = User_NAME() 修改为 select @CurrentUser = SCHEMA_NAME()

PowerDesigner 16.5对SQL Server 2012 生成数据库时"不支持扩展属性"问题

标签:

人气教程排行