select
replace(right('BAAU 1864175*2*201312170930*MBNP',CHARINDEX('_','BAAU 1864175*2*201312170930*MBNP')+27),'*','_')
It returns the result below
1864175_2_201312170930_MBNP
This is the result i want however I want it by subtracting the first words before the first space i.e in this case 'BAAU', the code i wrote is not actually doing this as it just adding +27 characters from the right but in some cases i have more than 27 characters after the first space, can some one please help me figure this out.
Many thanks