Qualifying tables without the “.” (or even rename fields in bulk)

Sometimes qualifying your tables is a necessary evil and does have its uses, however the tablename.fieldname syntax isn’t very friendly.

We can use a little script to whip through the data model and rename all of our fields to something friendlier for example tablename_fieldname

The only caveat is that it won’t rename a field to an existing field name (linked fields) so this still needs to be done manually, but if everything is qualified then you don’t have any links in the first place!

For vTable = 0 to NoOfTables() -1 
   Let vTableName = TableName(vTable); 
For f = 1 to NoOfFields('$(vTableName)') 
    let vFieldOld = FieldName($(f),'$(vTableName)'); 
    let vFieldNew = Replace('$(vFieldOld)','$(vTableName)'&'.','_'); 
    RENAME FIELD $(vFieldOld) to $(vFieldNew); 
Next f;  
Next ; 

Leave a Reply