I‘m an idiot.
there is no need to cast back and forth to varchar.

Can be replaced with basevalue + (ci+1) * 1 million

tomorrow….