Remove Join (Data Management)

License Level:BasicStandardAdvanced

Summary

Removes a join from a feature layer or table view.

Usage

Syntax

RemoveJoin_management (in_layer_or_view, {join_name})
ParameterExplanationData Type
in_layer_or_view

The layer or table view from which the join will be removed.

Mosaic Layer; Raster Catalog Layer; Raster Layer; Table View
join_name
(Optional)

The join to be removed.

String

Code Sample

Remove Join Example (Python Window)

The following Python window script demonstrates how to use the RemoveJoin tool in immediate mode in ArcMap on a feature layer in the TOC named veglayer.

arcpy.RemoveJoin_management("veglayer", "vegtable")
Remove Join Example 2 (Stand-alone Script)

This stand-alone script shows the RemoveJoin function as part of a workflow to add a field to a table and calculate its values based on the values in a field from a joined table.

# AddFieldFromJoin.py
# Description: Adds a field to a table, and calculates its values based
#              on the values in a field from a joined table

# Import system modules
import arcpy
from arcpy import env

try:
    # set the environments
    env.workspace = "C:/data"
    env.qualifiedFieldNames = "UNQUALIFIED"
    
    # Define script parameters    
    inFeatures = "Habitat_Analysis.gdb/vegtype"
    layerName = "veg_layer"
    newField = "description"
    joinTable = "vegtable.dbf"
    joinField = "HOLLAND95"
    calcExpression = "!vegtable.VEG_TYPE!"
    outFeature = "Habitat_Analysis.gdb/vegjoin335"
    
    # Add the new field
    arcpy.AddField_management (inFeatures, newField, "TEXT")
    
    # Create a feature layer from the vegtype featureclass
    arcpy.MakeFeatureLayer_management (inFeatures,  layerName)
    
    # Join the feature layer to a table
    arcpy.AddJoin_management (layerName, joinField, joinTable, joinField)
    
    # Populate the newly created field with values from the joined table
    arcpy.CalculateField_management (layerName, newField, calcExpression, "PYTHON")
    
    # Remove the join
    arcpy.RemoveJoin_management (layerName, "vegtable")
    
    # Copy the layer to a new permanent feature class
    arcpy.CopyFeatures_management (layerName, outFeature)
    
except Exception, e:
    
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013