Two days back, a colleague of mine asked How can he retrieve all rows which have similar employee names.
The situation, there are two tables/Excel sheets he has got from two different sources for the same set of employees. he needs to extract some information from both. the employee name column is the key to identity each one of these employees. the challenge here, employee name is not exactly the same in the two files.
The first solution jumped on the table is similar names. SQL Server provides us with some functions which will help us to achieve this task such as SOUNDEX() and DIFFERENCE().
Here is an example, assume there is a table like below
This table contains some of my friends’ names. as this table shows I have 5 friends share similar names with “Mhmd” letters but with different form for each one of them.
Now I want to write T-SQL query which should give me all friends whose name sounds similar “Mhmd”.
I wrote this query
SELECT FriendFisrtName, FriendLastName FROM MyFriends WHERE SOUNDEX('Mhmd') = SOUNDEX(FriendFisrtName)
And I got this result set
Hope this helps…
2 thoughts on ““Sound Like” Strings”
Ahan Nice One !