help with sql statement doing substrings and replace

Original text of this message