I think it works. Thank you. One more issue though.
I am not sure why but this part doesn't work WHEN S1UPSP LIKE 'RIOUS%' THEN '0'
Sometimes I have RIOUS932 or some other RIOUS% and I need to make them '0'. . What's wrong with this? WHEN S1UPSP LIKE 'RIOUS%' THEN '0'
WHEN LEFT(LTRIM(RTRIM(S1UPSP)),5) LIKE'%RIOUS%' THEN '0'
WHEN CHARINDEX(char(32), LTRIM(RTRIM(S1UPSP)), 1)>0 THEN '0'
WHEN LEN(S1UPSP)>8 THEN RIGHT(S1UPSP, 8)
WHEN S1UPSP = '' THEN '0'
END AS AR_LOAD,
The data type of S1UPSP is char.