Skill 1.3.5
Write queries that include fuzzy string matching functions, such as EDIT_DISTANCE, EDIT_DISTANCE_SIMILARITY, and JARO_WINKLER_DISTANCE
Key Concepts
EDIT_DISTANCE(a, b) returns the number of insertions, deletions, substitutions and transpositions needed to turn one string into another (the Damerau-Levenshtein optimal string alignment distance); an optional maximum distance stops early and returns the maximum plus one. EDIT_DISTANCE_SIMILARITY scales the result to an integer from 0 (no match) to 100 (identical), which is easier to compare across strings of different lengths.
JARO_WINKLER_DISTANCE returns a value from 0 (identical) to 1 and gives extra weight to strings that share a prefix, which suits short strings such as personal names; JARO_WINKLER_SIMILARITY returns 0 to 100. The functions are in preview: SQL Server 2025 needs the PREVIEW_FEATURES database scoped configuration, and they support Windows and binary collations but not non-binary SQL_ collations, which a COLLATE clause can work around. Because they compare pairs, matching a large table against itself benefits from blocking on a cheap key first, such as the first letter or postcode.