February 18, 2008 at 5:44 am
How to search in SQL for words that have 2 variations like
color & colour or
Paediatric & Pediatric.
I have many words like that...
February 18, 2008 at 7:01 am
If you want exact result, you need to specify exact predicates.
For similarity , you may want to experiment with soundex,...
There are examples at the SSC forums.
Read BOL for information on how it works.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 18, 2008 at 11:16 am
Search BOL for the LIKE operator, click on the "Pattern matching in search conditions" topic.
declare @Rows table (Word varchar(25))
INSERT INTO @rOWS values ('color')
INSERT INTO @rOWS values ('colour')
INSERT INTO @rOWS values ('pediatric')
INSERT INTO @rOWS values ('paediatric')
SELECT * FROM @Rows WHERE Word LIKE 'col[o]r'
SELECT * FROM @Rows WHERE Word LIKE 'col[o]r'
SELECT * FROM @Rows WHERE Word LIKE 'p[e]diatric'
SELECT * FROM @Rows WHERE Word LIKE 'p[a][e]diatric'
February 19, 2008 at 12:04 am
the downside for the patterns is that you have to know them at front.
The downside for soundex is that it is language dependent !
(i.e. English)
btw just like DIFFERENCE(T1.LName, T2.LName)
SELECT * FROM @Rows WHERE soundex(Word) = soundex('pediatric')
go
-- another test
declare @tmptest table (idnr int not null identity(1,1) primary key, LName varchar(50) not null , SoundexValue varchar(15))
insert into @tmptest (LName, SoundexValue)
select 'bijnens', soundex('bijnens')
union all
select 'bainens', soundex('baainens')
union all
select 'beinens',soundex('beinens')
union all
select 'beijnens', soundex('beijnens')
union all
select 'bynens', soundex('bynens')
union all
select 'bijnans', soundex('bijnans')
union all
select 'bijkans', soundex('bijkans')
union all
select 'janssen', soundex('janssen')
union all
select 'janssens', soundex('janssens')
union all
select 'jansen', soundex('jansen')
union all
select 'jans', soundex('jans')
union all
select 'sjans', soundex('sjans')
union all
select 'color', soundex('color')
union all
select 'colour', soundex('colour')
union all
select 'pediatric', soundex('pediatric')
union all
select 'paediatric', soundex('paediatric')
union all
select 'paedeatric', soundex('paedeatric')
union all
select 'peediatric', soundex('peediatric')
union all
select 'chans', soundex('chans');
Select T1.IdNr, T1.LName , T2.LName, T1.SoundexValue
from @tmptest T1
left join @tmptest T2
on T1.IdNr <> T2.IdNr
and soundex(T1.Lname) = soundex(T2.Lname)
order by T1.IdNr
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 19, 2008 at 2:31 pm
Not sure exactly what your trying to accomplish but I just got done writing a Phoentic Name search that our employees use to find existing customers in our system...
They can type "Johnson Company" and it'll search the system and display phonetic matches.
Like "Jonson Co.", "Johnsen Company", "Jonsen Co." etc...
I used the DBA Toolkit from this website:
There are limitations and quarks to it. Sometimes the matches are cleary not accurate but it works pretty good.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply