I'm exporting a layer from SDE to SHP by python script, and I'm doing it in 2 phases: the first includes select by location (for picking the relevant features) and the second phase includes the Select (Analysis) tool which exports the features to the output SHP.


The Select(Analysis) tool omits fields - in my case, OBJECTID and GLOBALID - which need to be in the output. (I know it's the tool's fault because when I do a manual data>export data, it exports the fields all fine and dandy.)

Does anybody know how I can fix this?

1 Answer 1


You are not losing any other fields except the global and object id right? These are database fields which are not necassary to a shapefile.

Check if you do a manual Select (analysis tool) not using python, or any other geoprocessing tool. They will remove the object and global ids as well. I would create new fields in your feature class with different names and copy the ids over to that, then run your python script and see what happens. All of your fields should still be in place.

I am not positive why this happens, but my guess is that geoprocessing tools have the potential to change a feature (not as apparent in a SELECT, but think clip), so the record is no longer the same as what was in SDE and should not have the same id. Like I said, not positive on the reason, but the solution of copying your attributes into a different named field should work.

  • A manual select (through the tool box)does not export them either, and that is why I'm asking this question, as I need to export all the fields, even non crucial ones like OID or GID... (the addition of columns is a nice workaround, unfortunately I can't edit the SDE).
    – jonatr
    Commented Apr 6, 2011 at 12:47
  • Ok, how about a normal export to shapefile, Data>Export Data. This will keep all of your fields in place (as well as add an index). Then run your python scripts on shapefiles rather than features?
    – badkins
    Commented Apr 6, 2011 at 13:22
  • do you mean a manual Data>Export data? I'm trying to avovide this as it needs to be done to a lot of layers. If you mean a tool, what tool do you use to do that? I used to use the select tool, but that's what lead to this question.
    – jonatr
    Commented Apr 7, 2011 at 9:04
  • UPDATE: I tried CopyFeatures_management and it doesn't export these fields either.
    – jonatr
    Commented Apr 7, 2011 at 9:11
  • Yeah I meant the manual data export. There is a multiple export feature class to shapefile tool in COnversion Tools>To Shapefile, but I beleive that is going to remove the object and global ids as well (as all geoproc tools will).
    – badkins
    Commented Apr 7, 2011 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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