I'm using arcpy in ArcGIS 10 to get a listing of all fields in datasources used by an MXD.
This works partially, but in some cases I get unqualified field names.
The piece of code I'm using to get field names for each layer is:
for field in arcpy.ListFields(lyr.name):
print " field:", field.name
This normally shows the fully qualified field name, but in some cases, especially when I have joins to another database (non-GDB), the field names are unqualified. At that point there seems to be no way to discover programmatically what table they belong to.
The forum topic Is there a way to Remove All Joins with Python? shows how to recover the names of tables, including joined tables, from ParseFieldName(). But this requires that the field name be qualified in the first place.
In ArcMap, when I look at the Fields tab of the layer properties, these particular fields have unqualified names here as well (but other fields have qualified names). So there's something deeper here than just the arcpy API hiding the qualified names.
In order to see the name of the joined table at all, I have to go to the Joins & Relates tab, and there I can see it. But I don't think there's a way to find this join information via arcpy; and even if I could, I would still need to know which fields came from that join. (Some layers have more than one join.)
Is there any way in Python to find out what table these fields come from, when their names are unqualified?
If it helps, I'm using ArcSDE with SQL Server 2005.
Thanks for any help.