How to get records who has phonetic similarity – a hidden feature in SQL SERVER TIP #49

Sometimes , It may required that you want a query who can provide you result which have phonetic similarity.

Lets understand this by example

Suppose you want to search a record whose pronunciation or phonetic sound are similar or close to then in that case you can use SOUNDEX property of  SQL SERVER which is a hidden feature and rarely used.

To understand it lets jump into the example.

Suppose you need to find records from people  table of adventureworks database whose firstname sound like “JOHN”

so to achieve this we will write following query

SELECT  FirstName,LastName
FROM Person.Person
WHERE SOUNDEX(FirstName)= SOUNDEX(‘John’)

It will return all those records whose firstname sounds like “John”

please see below screen for more detail

soundex'

I hope it may help you somewhere.

Enjoy !!!

RJ!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s