Automatically generate SQL Server field notes in PowerDesigner
PowerDesigner is a common design tool for database designers, but its native default generated code does not generate a field note description for the SQL Server database. It is cumbersome to manually modify the database after it has been generated.
First, we introduce a way to automatically generate a Memo field for SQL Server directly from PowerDesigner.
1. After establishing the physical model in PowerDesigner
2. In PowerDesigner, select the tool-->execute Commends-->edit/run Script and open the following dialog box:
3. Enter the following code in the dialog box:
Option Explicitvalidationmode=Trueinteractivemode=im_batch Dim MDL'The current model 'get the current active modelSet MDL=Activemodelif (MDL is nothing) then MsgBox"There is no current Model"ElseIf not MDL. IsKindOf (Pdpdm.cls_model) then MsgBox"The current model isn't an physical Data model."Else processfolder mdlend If'This routine copy name to comment for each table, each column and each view'Of the current folderPrivate Sub ProcessFolder (folder) Dim Tab'Running Table forEach TabinchFolder.tablesifNot Tab.isshortcut then tab.comment=tab.name Dim Col'Running Column forEach colinchtab.columns col.comment=col.name Next EndifNext Dim View'Running View forEach viewinchfolder. viewsifNot View.isshortcut then view.comment=View.name EndifNext'go into the sub-packagesDim F'Running FolderFor each f in folder. PackagesifNot F.isshortcut then ProcessFolder F endifNextEnd Sub
4. Click "Run" to execute the code. By previewing the SQL code of the physical model, you can see the database field comment code generated by PowerDesigner.
Automatically generate SQL Server field notes in PowerDesigner