I have a complex nested replace which I am using to join two tables in MSSQL.
select * from A
left outer join
select * from B
on
replace(
replace(
replace(
replace(
replace(A.Column1, '1114', ''),
'1160', ''),
'1162', ''),
'1167', ''),
'1176', ''),
'1177', '') = B.Column1
The whole reason I am doing this is because data in Table1 contains of some noise - numbers like 1160, 1162 etc wheres Table2 is clean characters.
Eg. - Table 1 - 'HELLO1160WORLD'
Table 2 - 'HELLOWORLD'
Now in my situation I should be able to match them as one entry.
My current approach of nested replace does work but I am not convinced that this is an elegant way to do this. Any help will be much appreciated. Thanks