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.

I already know how to do a table join with ArcObjects, via the IDisplayTable, IMemoryRelationshipClassFactory etc. interfaces. Here are some links to resources that have example code for this:

What I need to know is, how do I undo, i.e. remove such a join?

Once I've joined a standalone table to a feature layer, I end up with references to:

  • an IRelationshipClass (resulting from the join operation);

  • an ITable/IStandaloneTable/IDisplayTable (the table that was joined to the feature layer); and

  • an IFeatureLayer (the feature layer to which the table was joined).

Do these interfaces, or rather the objects behind them, allow unjoining at all? I've seen that IRelationshipClass has various DeleteRelationship… methods, but I can't see how they could work towards that end.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

Code below works for me for a featurelayer. Similar logic could be used for a standalone table.

private void RemoveAllJoins(IFeatureLayer fLayer)
    var dispTable = fLayer as IDisplayTable;
    var rqt = dispTable.DisplayTable as IRelQueryTable;
    if (rqt != null)
        Debug.Print("source: {0}", ((IDataset)rqt.DestinationTable).Name);
        Debug.Print("dest: {0}", ((IDataset)rqt.SourceTable).Name);
        fLayer.FeatureClass = (IFeatureClass)rqt.DestinationTable;
        Debug.Print("there are no joins");

The documentation for IRelQueryTable at 10 seems to be missing this important graphic, that appears in 8.3 help doc:

enter image description here

share|improve this answer
Is it really that simple!? Do you think that the assignment featureLayer.FeatureClass = destinationTable will also trigger the disposal of the MemoryRelationshipClass? That is, a memory relationship class doesn't have to be "undone" explicitly? –  stakx Jun 16 '11 at 12:22
I think a memoryrelationshipclass is used behind the scenes to create the relquerytable. The complications I see are handling cases where the renderer might be using related fields, or refreshing the tableview (if it is open). –  Kirk Kuykendall Jun 16 '11 at 13:46
thanks for your answer and the comment, which both provided me with the right clues. I ended up doing a different join than I thought (two IStandaloneTable via IMemoryRelationshipClass, then feeding that into a RelQueryTableFactory). Turns out the IMemoryRelationshipClass isn't all that important, as you said. –  stakx Jun 16 '11 at 21:39
+1 Perfect answer Kirk! –  Petr Krebs Jul 26 '11 at 20:49

It depends on your workflow, but you can always remove joins using built in geoprocessing. You just need the layer or table view and the name of your join.

Alternatively, like you were exploring, you can operate on the IRelationshipClass and call DeleteRelationshipsForObject. This requires you to be in an edit session and assumes you don't require any other joins to remain on the object you're working with.

share|improve this answer

The code above did not work for me with ArcGIS 10. It needs a little improvement:

IFeatureLayer2 actFeatLyr = focMap.get_Layer(i) as IFeatureLayer2;
ITable actLyr = focMap.get_Layer(i) as ITable;
IDisplayTable actDispTable = actFeatLyr as IDisplayTable;
IRelQueryTable actQueryTable = actDispTable.DisplayTable as IRelQueryTable;
IDisplayRelationshipClass actDispRelClass = actFeatLyr as IDisplayRelationshipClass;

actDispRelClass.DisplayRelationshipClass(null, esriJoinType.esriLeftInnerJoin);

I found the solution in the ArcGis 10 documentation, under the VBA-section, after hours of searching and trying with IRelationshipClass.

share|improve this answer
Thank you for sharing your experience with us. Welcome to our community! –  whuber Jul 26 '11 at 14:04
Just curious - what did the code I posted do when you ran it? What happens if you run it twice? –  Kirk Kuykendall Jul 26 '11 at 16:55

Your Answer


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.