• replace the untouchable 'BA#' first, then do the main replace, then put the 'BA#' back

    SELECT REPLACE(REPLACE(REPLACE(@STRING, 'BA#', '***'), 'A#', 'C#'), '***', 'BA#')