• Your question is almost verbatim the MSDN definition of SOUNDEX. http://msdn.microsoft.com/en-us/library/ms187384.aspx

    Now with the two phrases you listed the SOUNDEX would not be even close because the order of the words is different. We can leverage the age old DelimitedSplit8K here quite nicely. The idea here is order all words in each phrase alphabetically so we have a consistent order of the words for SOUNDEX.

    if OBJECT_ID('tempdb..#List') is not null

    drop table #List

    create table #List

    (

    ListID int identity,

    Phrase varchar(50)

    )

    insert #List

    select 'US Eastern District Court'

    union all

    select 'Eastern District Court of US'

    ;with List as

    (

    --First we need to split the values on the words

    select * from #List

    cross apply dbo.DelimitedSplit8K(Phrase, ' ')

    )

    , stuffedList as

    (

    --Now we sort the words alphabetically

    select ListID, STUFF((select Item + ' '

    from List l2

    where l2.ListID = l1.ListID

    order by Item

    for XML PATH('')), 1, 0, '') as FullList

    from List l1

    group by ListID

    )

    select *, SOUNDEX(FullList) from stuffedList

    Please see the link in my signature about splitting strings. In there you will find the code and the logic for how the DelimitedSplit8K function works.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/