I am doing a select query, and trying to join in another table where the common field in one table looks like “1234” and the other table has a comma and characters at the start like “BA,1234”.
Table1
ID |
---|
1234 |
12348 |
505 |
Table2
Case_No |
---|
BA,1234 |
BAC,12348 |
FETF,505 |
My join will be on TableI.ID = Table2.Case_No but I only want to grab the value of the case_no column to the right of the comma (“,”) so that I’m joining 1234 (Table1.ID) = 1234 (Table2.Case_No)
Is this possible with a combination of charindex and right function? Haven’t been able to get it to work.
Tried char index and right function but isn’t working at the moment
Jerome Silva is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.