In answer to comment above, arcpy.RemoveJoin_management raises an exception if there are no joins on the table. Also, ArcPy does not support update cursors on joined tables, even if the field being updated is in the base table. However, you can put arcpy.RemoveJoin_management inside a try block with no action on the exception if there are no joins.
A workaround to how to do an update from a field in a joined table is to create a dictionary from the the table that would be joined and use it as a lookup for the value of the non-key fields using the key field.
In this example code fragment, I have a table named LOCNAME which has a unique key field named "Loc_name" (which identifies a particular level of a composite address locator) and a non-key field "Descript" which gives a text description of the particular level.
I have already added the "Descript" field to the attribute table of a geocoded address list thisLayer containing the field "Loc_name" that identifies which level that particular address was geocoded, and I want to update the value of "Descript" using the corresponding value from the LOCNAME table.
try:
arcpy.RemoveJoin_management(thisLayer)
except:
pass
thisLayerDataSource = thisLayer.dataSource
theDescriptDict = {}
theLOCNAMECursor = arcpy.SearchCursor(theLOCNAMEDataSource)
for theLoc_name in theLOCNAMECursor:
theDescriptDict[theLoc_name.getValue("Loc_name")] = \
theLoc_name.getValue("Descript")
rows = arcpy.UpdateCursor(thisLayerDataSource, ["Descript", "CTCERTCODE", \
"CTCERTDESC", "SortMe"])
for row in rows:
thisLocName = row.getValue("Loc_name")
if ((thisLocName != ' ') and (thisLocName != '')):
thisDescript = theDescriptDict[thisLocName]
row.setValue("Descript", str(thisDescript))
If you have several fields in the second table, just make a dictionary for each field (still keyed by the same unique field) and using the UpdateCursor on the primary table, use row.setValue statements for each field.