Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kmstephenson
Creator
Creator

Rename all fields programmatically from each table in script

Hi All,

What is the best way to rename programmatically all fields in a given table with a "xx_" prefix related to the table name (but not the table name itself - and therefore not an alias or QUALIFY statement)?

Thanks!

21 Replies
Zaga_69
Creator
Creator

Hi Rob,

Thank you! now it is working, however since I have also some fields w/o blank spaces, i got a error message because the name already exists. Anyway to modify the loop to replace blank spaces ONLY for those fields with blank spaces?

Many thanks!

Zaga_69
Creator
Creator

Hi Rob,

I implemented this changes and now is working 🙂


For fieldIdx = 1 to NoOfFields('TempTable')
LET vFieldname =FieldName($(fieldIdx), 'TempTable');
LET vFieldBlankCount=SubStringCount('$(vFieldname)',' ');
LET vFieldnameModified =if('$(vFieldBlankCount)'>0,Replace('$(vFieldname)', ' ' ,'_'),'');
RENAME Field [$(vFieldname)] TO $(vFieldnameModified);
// LET vFieldname= null();
// LET vFieldnameModified = null();
Next fieldIdx