Smart Search Without AI: A Practical Guide to SQL Fuzzy Matching

SQL's native fuzzy matching functions Damerau-Levenshtein and Jaro-Winkler fill in literal similarity matching beyond AI.
Microsoft's Data Exposed introduces AI-free fuzzy string matching in SQL. Real-world data often contains typos, character transpositions, and regional differences; traditional Soundex and Difference rely only on pronunciation and cannot handle transpositions. SQL is introducing Damerau-Levenshtein edit distance, which supports a single adjacent transposition (changing form to from in one operation), and Jaro-Winkler similarity, which weights common prefixes to match how users typically type correctly at the start. Similarity scores derive from edit distance and max length. In practice, you can set a max distance parameter to short-circuit computation and combine multiple conditions like name and postal code for deduplication. For selection: exact matches use equals or regex, literal similarity uses fuzzy matching, and semantic similarity turns to vector search.
In an era where AI search and vector search dominate the spotlight, Microsoft's Data Exposed program turns its attention to another often-overlooked area: fuzzy matching without relying on AI. Host Anna Hoffman and guest Abhiman dive deep into the fuzzy string matching capabilities built into SQL and how to use them to build smarter search systems.
Why Do We Need Fuzzy Matching?
Real-world data is rarely perfect. Typos, missing letters, swapped characters, and regional spelling differences (like American English's color vs. British English's colour) are everywhere. Abhiman points out that even with AI spell-check enabled, errors like typing "form" instead of "from" may not get corrected.
The core of fuzzy matching is measuring how similar two words or two sentences are, rather than requiring an exact match. It applies to many scenarios: deduplicating customer data across systems, entity alignment, OCR error correction (such as recognizing the digit 0 as the letter O), and quality validation when AI models read data.

Traditional Approaches: Soundex and Difference
SQL actually has long had fuzzy matching functions like Soundex and Difference. They work on phonetic principles: Soundex converts a word into a code starting with its first letter, and Difference compares two Soundex codes and returns a score from 0 to 4, with 4 being the most similar. This approach has existed for years and suits matching needs where pronunciation is close.
But its limitations are obvious: it only considers pronunciation, not spelling structure. For common errors like character transposition, Soundex is powerless.
Soundex is one of the earliest phonetic encoding algorithms, invented by Robert C. Russell and Margaret King Odell in 1918 and later incorporated into U.S. Census data processing in the mid-20th century. Its core rule is to keep the first letter of the word, map subsequent consonants to digits by phonetic category (for example, b, f, p, and v fall into the same class), and discard vowels and letters like h, w, and y, ultimately producing a fixed-length code of "letter + three digits." Thus Robert and Rupert yield the same Soundex code R163. The Difference function directly compares two Soundex codes and returns an integer score from 0 to 4, with 4 meaning identical codes. This mechanism is very effective for matching names with similar pronunciation, but it completely ignores vowels and spelling structure and cannot handle non-phonetic errors such as character transposition or missing letters.
New Capabilities: Damerau-Levenshtein and Jaro-Winkler
Microsoft is bringing two more powerful algorithms into SQL and plans to release them officially across all Microsoft SQL product lines.
Damerau-Levenshtein Edit Distance
This algorithm is based on Optimal String Alignment (OSA) and computes the minimum number of edits needed to make two strings identical. Edit operations include insertion, deletion, substitution, and transposition.
Transposition support is a key advantage. Changing "form" to "from" requires only one transposition, whereas plain Levenshtein distance needs two edits (delete then insert). Abhiman specifically emphasizes that the SQL implementation is a restricted version supporting only single adjacent character transpositions, because the full algorithm consumes a large amount of memory and is impractical on large datasets.

Levenshtein Distance was proposed by Soviet mathematician Vladimir Levenshtein in 1965 and is defined as the minimum number of single-character edit operations—insertion, deletion, and substitution—required to transform one string into another. Frederick Damerau later introduced a fourth operation—adjacent character transposition—in his 1964 work, forming the prototype of the Damerau-Levenshtein distance. The full Damerau-Levenshtein algorithm allows any number of transpositions, but its dynamic programming implementation must maintain a larger state matrix, resulting in significant memory overhead on long strings and large-scale datasets. SQL products often adopt a restricted version, namely Optimal String Alignment (OSA), which allows each character to participate in at most one transposition and no overlapping adjacent transpositions, thereby keeping memory complexity within an acceptable range while retaining the main practical value.
Jaro-Winkler Similarity
Jaro-Winkler also measures string similarity but gives extra weight to a common prefix. When the starting characters of two words match better, the score is higher. This aligns with intuition: users usually type the beginning correctly and make errors later on.
The Jaro similarity was extended by William E. Winkler in the 1990s based on Matthew Jaro's 1989 work, originally for name matching at the U.S. Census Bureau. Jaro similarity computes a score by counting the number of "matching characters" in two strings and the number of transpositions among those matches, with the matching window size typically set to half the larger of the two string lengths minus one. Winkler's improvement introduces a prefix scaling factor: extra credit is given for consecutive identical characters at the start of the two strings, with the scaling factor usually set to 0.1 and a maximum prefix length of 4 characters. This makes Jaro-Winkler particularly sensitive to inputs where "the beginning is correct but the tail is wrong," which fits the typical error pattern when users type data. Its score ranges from 0 to 1, with 1 meaning identical, and it is widely adopted in entity matching tasks such as names and addresses.
How Are Similarity Scores Calculated?
For Damerau-Levenshtein, the similarity formula is: 1 - edit distance / max length, then multiplied by 100. For the same edit distance, shorter strings are affected relatively more. For example, deleting 1 character from a 4-character string yields a similarity of 75, while deleting 1 character from a 6-character string yields 83.
When to Use Which Algorithm?
The choice depends on your needs:
- Need to know the exact number of edits: use Damerau-Levenshtein edit distance
- Character alignment and prefix matching are important signals: use Jaro-Winkler
- Phonetic similarity is enough: use Soundex/Difference
- Semantically similar but literally completely different (such as car and automobile): fuzzy matching does not apply; use semantic search capabilities like vector search instead
You can also combine them to complement each other's strengths.

Vector search and fuzzy matching solve problems at different levels. Vector search maps text into high-dimensional vectors via embedding models and then measures semantic closeness based on cosine similarity or inner product, so it can recognize expressions that are literally very different but close in meaning, such as car and automobile, or doctor and physician. Fuzzy matching stays at the character level and measures surface-level spelling closeness without semantic understanding. The two are not substitutes: in a data cleaning pipeline, you can first use fuzzy matching to handle spelling variants and OCR noise, then use vector search for semantic-level entity alignment and intent matching. Understanding this division of labor helps place the right tool at the right stage in architecture design, avoiding using fuzzy matching to solve semantic problems and avoiding introducing unnecessary embedding model overhead for simple spelling correction.
Practical Tips: Max Distance and Fault-Tolerant Queries
A practical optimization is to set a max distance parameter. If you only care about matches within edit distance 2, you can pass max distance=2. When the actual distance exceeds the threshold, the function returns "max distance + 1" instead of performing a full computation, saving processing overhead while avoiding ambiguous results at the threshold boundary.
In deduplication scenarios, you can combine multiple conditions. For example, match both name and postal code: first use fuzzy matching to filter similar names, then require the postal code to be identical, and finally require a similarity score of 92 or above to return. This filters out records like Robert that do not match.

In OCR correction scenarios, by accounting for confusion between the digit 0 and the letter O and setting a filter of edit distance ≤ 1, you can screen out likely recognition errors. When an AI reads a name and validates it, you can set similarity ≥ 80 as the pass threshold.
Capability Selection Cheat Sheet
Abhiman concludes with selection advice:
- Exact matching: for known values, use the equals sign; for complex patterns, use regular expressions
- Fuzzy matching: for spelling differences, character transpositions, OCR errors, and similar scenarios
- Semantic search: when the question is about "meaning" rather than "literal form," turn to vector search
Fuzzy matching is not meant to replace AI search but to fill in a key piece of the puzzle beyond AI. For high-frequency needs like data cleaning, deduplication, and fault-tolerant queries, native SQL functions are often the most direct and efficient solution, with no need to introduce additional AI infrastructure.
Related articles

Prompt Engineering for Beginners: From Writing Prompts to Engineering Thinking
Starting from the essence and four functions of prompts, this article systematically explains the six-step process, four success criteria, learning value, and practical limitations of prompt engineering to help you build a complete understanding.

Anthropic Launches Nasdaq IPO: AI Giant's Listing and Risk Disclosures
Anthropic officially launches its Nasdaq IPO under ticker ANT, with market valuation expected to potentially exceed SpaceX's record. The prospectus devotes nearly 100 pages to AI risks, while first-half revenue grew over 14x but net losses widened sharply, reigniting the AI bubble debate.

Rust cURL Clone Uses 4,832 unsafe Blocks—Is the Memory Safety Myth Broken?
A Rust cURL clone uses 4,832 unsafe keywords, challenging Rust's memory safety narrative. We analyze what unsafe really means, compare Fil-C, and examine rewrite motives.