When or is it NEC code compliant to upgrade a 2-wire circuit, by adding a third prong equipment ground from a nearby cold water pipe?
A different case of borrowing a ground from a nearby circuit is covered at: Is it OK to borrow a ground wire from a different circuit? (the short answer is it's now OK in the USA).
I am aware that this method of grounding was once common. However a water pipe ground is subject to issues in future partial re-plumbing, which may involve isolating pipe with a dielectric union:
Best Answer
Never!
Article 250.118 of the National Electrical Code lists the approved methods of equipment grounding. Water piping systems are NOT listed there.
Metal piping systems within buildings are required to be bonded to the electrical grounding system to prevent them from becoming energized. They are not used AS an equipment grounding conductor for circuits.
Spend the time, effort, and money to run a separate equipment ground back to the service panel or to another circuit with a ground as you cited in the other example.
Good luck!