The 2" PVC elbow shown in these pictures is leaking at the joint where it connects with a PVC pipe coming through the foundation stem wall at the right.
What's the best procedure for replacing this elbow? Is it possible to remove the elbow without damaging the wall pipe that it connects to?
I'm willing to replace all of the pipe and fittings above and to the left of the elbow and that lead to the sump pump. However, I hope to avoid replacing the pipe that comes through the stem wall, since that would involve excavating outside the house.
It's almost impossible to remove cemented PVC fittings without damaging the pipe they're attached to. You can try to cut slots in the elbow with a rotary tool and break away the elbow piece by piece but any scoring of the pipe will cause leaking with a new elbow. If you succeed in removing the elbow, you could attach a Fernco coupling (see picture below)to the pipe out of the wall and to additional piping to complete your run.
In all honesty, I think replacing the wall pipe would be your best bet. That pipe might have been too short to begin with so the elbow wasn't properly installed in the first place.
Stud pak had a great video on the various options on removing a solvent welded pvc or abs pipe. I think the heat gun worked best. The short of it is you'd use a osc or recip saw to cut the pvc 90 at the far side of the hub and then use the heat gun to remove the hub from the pipe then you could put a new 90 onto the pipe.