Sadly, I had to look up the syntax for replace and I'm assuming that you mean using the print function when you refer to messages? Or are you talking about raiseerror.
Hint: Requires Left, Right, LEN, and PatIndex You could also write it with Substring if you enjoy pain or are more comfi.
I would accept Print or Select. Really knowing the differences is trivial. Seeing whether you can think through the problem is more interesting.
'You' being sample candidate.
I'm not sure if you changed the criteria, but once you declare the missing variables and load them up, the replacement requires 1 line of code:
Select @NewPath = REPLACE(@OldPath, @OldNode, @NewNode)
Am I missing something?