Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In the Answer to somebody else's question it was stated that the Make Query Table tool could be used to re-order fields in tables and feature classes permanently.

However, when I open the dialog for that tool I cannot see anywhere that enables re-ordering of fields. All I can see is that fields can be carried through or dropped using checkboxes but in the same order.

Assuming that it is possible can someone describe the steps in more detail, please?

Make Query Table tool dialog

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

I figured out how to do this by using the Make Query Table tool, Copy As Python Snippet, the Python window and the Copy Features tool.

After running the Make Query Table tool to pull through just the fields I wanted to appear in the output I was able to Copy As Python Snippet this code from the Geoprocessing | Results window into the Python window of ArcMap.

arcpy.MakeQueryTable_management("'C:/avhome/data/WAregional/wa regional.mdb/schools'","QueryTable","USE_KEY_FIELDS","#","schools.OBJECTID #;schools.Shape #;schools.CODE #;schools.NAME #;schools.TYPE #;schools.Y11STUDENT #;schools.Y12STUDENT #;schools.COORDGEOCO #;schools.ID #","#")

and edit it to become:

arcpy.MakeQueryTable_management("'C:/avhome/data/WAregional/wa regional.mdb/schools'","QueryTable2","USE_KEY_FIELDS","#","schools.OBJECTID #;schools.Shape #;schools.Y12STUDENT #;schools.Y11STUDENT #;schools.NAME #","#")

Note that the new QueryTable2 retains the Shape field (so I can CopyFeatures it) and I have reordered the NAME,YR11STUDENT & YR12STUDENT fields. I also used the opportunity to drop out a few more fields.

The last step is to use the Copy Features tool on QueryTable2 which I did via its tool dialog to create a new feature class with the fields re-ordered permanently.

share|improve this answer
2  
Note: you can also use MakeQueryTable to change the names of your fields by inputting a list of lists of field names and aliases ([[fieldname1,alias1],[fieldname2,alias2]...]) –  gotanuki Dec 25 '12 at 18:02
    
The same functionality is exposed when you run Feature class to Feature class and then Copy As Python Snippet. –  Alex Tereshenkov Apr 5 at 8:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.