To replace a polyvinyl chloride (PVC) drain pipe, coat it with primer, coat the inside part on top of the coupler with glue, thread both ends of the drain pipe, and attach joint compounds to prevent leaks. Place the sleeve or coupler inside of the replacement pipe, being careful not to smear the glue. Repeat this process for the other end of the new drain pipe. Coat the ends of the replacement pipe with solvent, and set it in place.
Before starting to replace the drain pipe, put on water-resistant gloves, and cover yourself with a plastic sheet to prevent water from getting on your clothes. After that, carefully inspect the pipe to find the area that needs to be replaced, and use a hack saw to cut that part of the pipe out. Make sure to bring that piece of the pipe along when buying a replacement at a hardware store in order to choose the exact same pipe.
Before installing the pipe, try placing the coupling in the pipe to ensure they fit together well. Smooth out the edges of the old pipe with a putty knife. Make sure that the size of the replacement pipe is the same as the size of the piece that was cut out. Use fine-grit sandpaper to treat the top of the replacement pipe.