Levenshtein Distance Function

Copper Contributor

Our current SQL server 2017 doesn't have built-in function for calculating Levenshtein distance.  I know Microsoft has that function somewhere.  How can we obtain such built-in function from Microsoft?

 

Thanks,

 

Justin

3 Replies

@XinyuTan 

 

Hey, Justin.

 

It doesn't exist in SQL Server (deliberately excluding Master Data Services), but you can achieve a similar outcome using DIFFERENCE:

 

 

You could look at authoring your own SQL CLR-based function using the Spark library, but this isn't particularly portable since you cannot add CLR-based functions to the more affordable Azure SQL options (only Azure SQL MI can handle CLR functions):

 

 

Cheers,

Lain

@LainRobertson 

 

Lain,

 

Thank you for the explanations and those reference links!

 

Justin

@XinyuTan 


Our current SQL server 2017 doesn't have built-in function for calculating Levenshtein distance. 

No version of SQL Server do have the Levenshtein distance algorythm as build-in function, you have to implement it on your own.

 

I know Microsoft has that function somewhere.

No, not for SQL Server, only in the Cloud

levenshtein function - Azure Databricks - Databricks SQL | Microsoft Learn