SQL Server/T-SQL/String Functions/Difference

Материал из SQL эксперт
Версия от 10:19, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

DIFFERENCE(): a wrapper around two SOUNDEX() function calls and some business logic to compare the values

1> -- DIFFERENCE(): a wrapper around two SOUNDEX() function calls and some business logic to compare the values.
2>
3> -- reducing the result to a scale from 0 to 4, where the value 4 indicates a very close or exact match.
4>
5> SELECT DIFFERENCE("To", "Two")
6>
7> GO
-----------
          4
(1 rows affected)
1>



DIFFERENCE: work out when one string sounds similar to another string

1> -- DIFFERENCE: work out when one string sounds similar to another string.
2>
3> -- "0" means that the two strings aren"t even close,
4> -- "4"   means a perfect match
5>
6> DECLARE @s1 varchar(6)
7> DECLARE @s2 varchar(6)
8> SET @s1 = "Dewson"
9> SET @s2 = "Joosun"
10>
11> SELECT DIFFERENCE(@s1,@s2)
12> GO
-----------
          3
(1 rows affected)
1>



SELECT DIFFERENCE ( "Fleas", "Fleece")

 
4>
5> SELECT DIFFERENCE ( "Fleas", "Fleece")
6> GO
-----------
          3
(1 rows affected)
1>
2>



Using the DIFFERENCE() function to compare Redmond with Renton

1> -- Using the DIFFERENCE() function to compare Redmond with Renton
2>
3> SELECT DIFFERENCE ("Redmond", "Renton")
4> GO
-----------
          3
(1 rows affected)
1>