Traverse all tables in the physical model in PowerDesigner, check the table code, field code

Source: Internet
Author: User
Tags powerdesigner

' ***************************************************************************** ' File: CheckCode4SqlServer.vbs ' Version: 1.0 ' function: Traverse all the tables in the physical model, check the table code, the field code ' contains spaces, whether it contains Chinese, is a system keyword, is longer than 116 ' usage: Open the physical model, run this script (ctrl+shift+x) ' Remarks: ' ********** Dim model ' current Model set model = Activemodel If (model is Nothing) Then MsgBox "No model selected, select a model and open." ElseIf not model. IsKindOf (Pdpdm.cls_model) then MsgBox "is not currently selected as a physical model (PDM)." Else processtables model End If ' ***************************************************************************** ' Procedure: Processtables ' function: recursive traversal of all tables ' ***************************************************************************** Sub Processtables (folder) ' handles tables in the model Dim table for each table in Folder.tables if not table.       Isshortcut then on Error Resume Next ' Check the table name for special characters, is the keyword check table.code, ' "" Dim Col For each of the Col in table. Columns ' Check if there are special characters in the field name, whether it is a keyword check cOl.code, Table.code next End If Next ' sub-directory is recursively Dim subfolder for each subfolder in folder. Packages processtables subfolder Next End Sub ' ******************************************************************* ' Procedure: Check ' function: Checking the table name or field name ' *****************************************************************************  Sub Check (str, tablecode) Dim outstr If Len (tablecode) > 0 Then outstr = "field name" & Tablecode & "."    else outstr = "Table name" End If ' check indicates whether a special character is included if InStr (str, "") Then Outstr = outstr & str & "contains spaces" Output outstr End If ' contains Chinese if haschinese (str) Then outstr = outstr & str & "contains Chinese" Output outstr end If ' Detect system keyword Dim arr arr = Array ("ADD", "EXTERNAL", "PROCEDURE", "All", "FETCH", "public", "ALTER", "FILE", "RAISERROR", "and" , "FILLFACTOR", "READ", "any", "for", "READTEXT", "as", "FOREIGN", "RECONFIGURE", "ASC", "FREETEXT", "REFERENCES", " AUTHORIZATION "," freetexttable "," REPLICATION "," BACKUP "," RESTORE "," BEGIN ","Full "," RESTRICT "," between "," FUNCTION "," RETURN "," Break "," GOTO "," REVERT "," BROWSE "," GRANT "," REVOKE "," BULK "," GROUP "Right", "by", "have", "ROLLBACK", "CASCADE", "HOLDLOCK", "ROWCOUNT", "Case", "IDENTITY", "ROWGUIDCOL", "CHECK", " Identity_insert "," RULE "," CHECKPOINT "," Identitycol "," SAVE "," CLOSE "," IF "," SCHEMA "," CLUSTERED "," in "," Securityaudit "," Coalesce "," INDEX "," select "," COLLATE "," INNER "," semantickeyphrasetable "," COLUMN "," INSERT "," Semanticsimilaritydetailstable "," COMMIT "," INTERSECT "," semanticsimilaritytable "," COMPUTE "," into "," Session_user " , "CONSTRAINT", "is", "SET", "CONTAINS", "JOIN", "SETUSER", "ContainsTable", "KEY", "SHUTDOWN", "CONTINUE", "KILL", "SOME" , "CONVERT", "left", "STATISTICS", "CREATE", "like", "System_user", "Cross", "Lineno", "TABLE", "current", "LOAD", " Tablesample "," current_date "," MERGE "," TEXTSIZE "," Current_time "," national "," then "," Current_timestamp "," NOCHECK ", "Current_User", "nonclustered", "TOP", "CURSOR", "not", "TRAN", "DATABASE", "NULL", "TRANSACTION", "DBCC", "Nullif", " TRIGGER "," deallocate "," of "," TRUNCATE ","DECLARE "," OFF "," Try_convert "," DEFAULT "," offsets "," tsequal "," DELETE "," on "," UNION "," DENY "," OPEN "," UNIQUE "," DESC " , "OpenDataSource", "UNPIVOT", "DISK", "OPENQUERY", "UPDATE", "DISTINCT", "OPENROWSET", "UpdateText", "distributed", " OPENXML "," Use "," DOUBLE "," OPTION "," USER "," DROP "," OR "," VALUES "," DUMP "," ORDER "," VARYING "," ELSE "," OUTER "," VIEW "," END "," Over "," WAITFOR "," Errlvl "," PERCENT "," when "," ESCAPE "," PIVOT "," WHERE "," EXCEPT "," PLAN "," while "," EXEC "," PRECISION "," with "," EXECUTE "," PRIMARY "," Within GROUP "," EXISTS "," PRINT "," WriteText "," EXIT "," PROC ") for each keyword   In arr if UCase (str) = keyword then outstr = outstr & str & "for system keyword" Output outstr End If Next ' If the string length exceeds the limit if Len (str) >= outstr = outstr & str & "named length should not exceed" Output outstr End IfEnd Sub ' ***************************************************************************** ' function: HasChinese ' function: Contains Chinese ' * * * *  function Haschinese (str) Haschinese = False Dim i for I=1 to Len (str) if ASC (Mid (str,i,1)) < 0 Then Haschinese = True Exit  For End If Next End function

Traverse all tables in the physical model in PowerDesigner, check the table code, field code

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.