PowerDesigner16导出Sql修复
2015-12-01 14:38
393 查看
最近在对公司的系统做重构,用了pd16,导出到sqlserver2008时,出了一些问题,以前碰到过解决了,但再次碰到时,还是要查阅资料,所以这次把解决办法分享出来。
一,在数据库中创建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)
二,修改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 and name = 'MS_Description')
begin
[%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%
:declare @CurrentUser sysname
select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%
]
end
][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%
:select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%
]
三,修改Column ColumnComment模板 路径是 Database -> Edit Current DBMS 窗体 General 选项卡 下 Script -> Objects -> Column -> ColumnComment
[if exists (select 1
from sysproperties
where TableID = object_id('[%QUALIFIER%]%TABLE%')
and ColName = %.q:COLUMN% AND PropName='MS_Description')
begin
[%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
:declare @CurrentUser sysname
select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
]
end
][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
:select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
]
一,在数据库中创建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)
二,修改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 and name = 'MS_Description')
begin
[%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%
:declare @CurrentUser sysname
select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%
]
end
][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%
:select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%
]
三,修改Column ColumnComment模板 路径是 Database -> Edit Current DBMS 窗体 General 选项卡 下 Script -> Objects -> Column -> ColumnComment
[if exists (select 1
from sysproperties
where TableID = object_id('[%QUALIFIER%]%TABLE%')
and ColName = %.q:COLUMN% AND PropName='MS_Description')
begin
[%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
:declare @CurrentUser sysname
select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?
]'MS_Description',
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
]
end
][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]%.q:OWNER%, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
:select @CurrentUser = user_name()
[.O:[execute ][exec ]]sp_addextendedproperty [%R%?
]'MS_Description',
[%R%?
]%.q:COMMENT%,
[%R%?
]'user', [%R%?
]@CurrentUser, [%R%?
]'table', [%R%?
]%.q:TABLE%, [%R%?
]'column', [%R%?
]%.q:COLUMN%
]
相关文章推荐
- Ubutun下搭建MySQL用户验证的WebDav服务器
- mysql 忘记root密码
- sqlplus
- SQL 测验
- 【问题】 Navicat 2003-can't connect to MYSQL server on 'localhost'(10061)
- sql根据字段查询重复记录
- Oracle 非dba用户 使用 set autotrace 功能
- oracle调用存储过程和函数返回结果集
- oracel 到、导入导出数据库
- mysqli的初步学习
- PL/SQL Developer记住用户名密码
- 怎样让Oracle的存储过程返回结果集
- 利用ssh遍历数据库的奇技淫巧
- Redis (error) ERR operation not permitted
- mysql启动错误
- 解决mysql数据库不能支持中文的问题
- InnoDB引擎Myslq数据库数据恢复
- 优化SQLServer--表和索引的分区(二)
- SQL Server 获取刚插入数据的ID号
- Oracle存储过程 使用游标、数组的配合查询