Use powerdesigner 15 to generate SQL Server Chinese comments

Source: Internet
Author: User
Tags powerdesigner

Problem description

After you create an SQL Server database using an SQL script generated by Power Designer (PD), the description of the table and field becomes garbled, such ????, After Google has published some related articles, there is no good solution, either for MySQL, Oracle, or SQL Server.

Solution

Start to think that is generated by the PD script file encoding is not correct, modify the encoding to simplified Chinese gb2312 can not; modify the database collation for Chinese-PRC-CI-AS is not good. Later, I directly created a test table on SQL Server, added comments, and exported scripts as follows:

Note generated by PD:

Execute sp_addextendedproperty 'Ms _ description ',

'Attachment ',

'User', 'dbo', 'table', 'wf _ attchment'

Go

 

Execute sp_addextendedproperty 'Ms _ description ',

'Attachment id ',

'User', 'dbo', 'table', 'wf _ attchment ', 'column', 'attchmentid'

Go

Notes generated by SQL Server:

Exec sys. sp_addextendedproperty @ name = n' MS _ description', @ value = n' attachment id', @ level0type = n' schema ', @ level0name = n' dbo ', @ level1type = n' table ', @ level1name = n' WF _ attchment', @ level2type = n' column ', @ level2name = n' attchmentid'

Go

 

After comparing the script generated by PD with the script exported by SQL Server, it is found that N is attached to the value assigned to the comment. After finding the root cause of the problem, it is easy to handle it. We need to handle it in the PD.

1. Modify the language attribute of the database model in PD | database | gernate datebase | format and change the language to UTF-8, as shown in:

2. Modify the annotation of the generated script. The modification is as follows:

Tools --> resources --> DBMS --> SQL Server 2008 open the DBMS Properties window, select Microsoft SQL Server 2008 on the General tab --> script --> objects, you can modify the table comment-Table comment and column comment-field comment in objects,

 

/Table comment/

/Default table comment/

[% Owner %? [. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[% R %? [N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] %. Q: Owner %, [% R %? [N] 'table', [% R %? [N] %. Q: Table %

: Declare @ currentuser sysname

Select @ currentuser = user_name ()

[. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[% R %? [N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] @ currentuser, [% R %? [N] 'table', [% R %? [N] %. Q: Table %

]

/Comment on the modified table/

[% Owner %? [. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[[N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] %. Q: Owner %, [% R %? [N] 'table', [% R %? [N] %. Q: Table %

: Declare @ currentuser sysname

Select @ currentuser = user_name ()

[. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[[N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] @ currentuser, [% R %? [N] 'table', [% R %? [N] %. Q: Table %

]

////////////////////////

/Field comment/

 

/Default field comment/

[% Owner %? [. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[% R %? [N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] %. Q: Owner %, [% R %? [N] 'table', [% R %? [N] %. Q: Table %, [% R %? [N] 'column', [% R %? [N] %. Q: column %

: Declare @ currentuser sysname

Select @ currentuser = user_name ()

[. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[% R %? [N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] @ currentuser, [% R %? [N] 'table', [% R %? [N] %. Q: Table %, [% R %? [N] 'column', [% R %? [N] %. Q: column %

]

/Comment the modified field/

[% Owner %? [. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[[N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] %. Q: Owner %, [% R %? [N] 'table', [% R %? [N] %. Q: Table %, [% R %? [N] 'column', [% R %? [N] %. Q: column %

: Declare @ currentuser sysname

Select @ currentuser = user_name ()

[. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[[N] %. Q: Comment %,

[% R %? [N] 'user', [% R %? [N] @ currentuser, [% R %? [N] 'table', [% R %? [N] %. Q: Table %, [% R %? [N] 'column', [% R %? [N] %. Q: column %

]

You can also modify the field annotation as follows:

/Comment the modified field/

[% Owner %? [. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[[N] %. Q: Comment %,

[% R %? [N] 'scheme', [% R %? [N] %. Q: Owner %, [% R %? [N] 'table', [% R %? [N] %. Q: Table %, [% R %? [N] 'column', [% R %? [N] %. Q: column %

: Declare @ currentuser sysname

Select @ currentuser = user_name ()

[. O: [execute] [exec] sp_addextendedproperty [% R %? [N] 'Ms _ description ',

[[N] %. Q: Comment %,

[% R %? [N] 'scheme', [% R %? [N] @ currentuser, [% R %? [N] 'table', [% R %? [N] %. Q: Table %, [% R %? [N] 'column', [% R %? [N] %. Q: column %

]

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.