SQL Server/T-SQL/String Functions/SOUNDEX

Материал из SQL эксперт
Перейти к: навигация, поиск

SOUNDEX: check how similarly sounding two tested strings can be

   <source lang="sql">

1> -- SOUNDEX: check how similarly sounding two tested strings can be. 2> 3> SELECT SOUNDEX("Robin Dewson"), SOUNDEX("Robyn Jewshoon") 4> GO


-----

R150 R150 (1 rows affected) 1>

      </source>
   
  


SOUNDEX(): make quantitative comparisons

   <source lang="sql">

1> 2> -- SOUNDEX(): make quantitative comparisons. 3> 4> DECLARE @Word1 VarChar(100) 5> DECLARE @Word2 VarChar(100) 6> DECLARE @Value1 Int 7> DECLARE @Value2 Int 8> DECLARE @SoundexDiff Int 9> 10> SET @Word1 = "Joe" 11> SET @Word2 = "Joose" 12> SELECT @Value1 = CONVERT(Int, SUBSTRING(SOUNDEX(@Word1), 2, 3)) 13> SELECT @Value2 = CONVERT(Int, SUBSTRING(SOUNDEX(@Word2), 2, 3)) 14> SET @SoundexDiff = ABS(@Value1 - @Value2) 15> 16> PRINT @SoundexDiff 17> GO 200 1>

      </source>