SQLTeam.com | Weblogs | Forums

Compare the two text fields of two different tables


#1

HI Friends,

I have a table x with field Address and table y with fields customer_Address., Customer_Name etc

I want to compare tables x and y on the address fields and grab Customer_name . But the address field in x and Customer_address field in y may few of the strings in slight different manner . I want to do the best of comparison.

Please suggest some good ways to do it.

This is what I have done but seems to be very slow.

SELECT x.StreetAddress,y.FULL_ADDRE,t.CITY,x.city,x.LATITUDE,x.LONGITUDE from
x
inner join
Y
on x.StreetAddress LIKE '%' + y.FULL_ADDRE + '%'
and x.City LIKE '%' + y.City + '%'
where x.StateId =22


#2

Please post table scripts and sample data,so that it is easy to help and you get the desired result.


#3

You'll need sample data there. The query you posted seems to imply that the "y" table holds the data in exactly the same format, somewhere in the middle of a string ie with garbage either side of it.

Is this the case? I assume this is for a data cleansing exercise, and to fix the data structure?