หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Applies to:
SQL Server 2025 (17.x)
Azure SQL Database
Azure SQL Managed Instance
SQL analytics endpoint in Microsoft Fabric and Warehouse in Microsoft Fabric
SQL database in Microsoft Fabric
Calculates the edit distance between two strings giving preference to strings that match from the beginning for a set prefix length.
Note
JARO_WINKLER_DISTANCEis generally available starting with SQL Server 2025 (17.x) CU11. On earlier SQL Server 2025 builds, the function is in preview. If it isn't enabled by default on your build, enable PREVIEW_FEATURES by setting it toON.JARO_WINKLER_DISTANCEis available in Azure SQL Managed Instance with the SQL Server 2025 or Always-up-to-date update policy.
Syntax
JARO_WINKLER_DISTANCE (
character_expression
, character_expression
)
Arguments
character_expression
An alphanumeric expression of character data. character_expression can be a constant, variable, or column. The character expression can't be of type varchar(max) or nvarchar(max).
Return value
float
Remarks
This function implements the Jaro-Winkler edit distance algorithm.
Examples
A. Calculate Jaro-Winkler distance between two words
The following example compares two words and returns the JARO_WINKLER_DISTANCE value as a column, named Distance.
SELECT 'Colour' AS WordUK,
'Color' AS WordUS,
JARO_WINKLER_DISTANCE('Colour', 'Color') AS Distance;
Returns:
WordUK WordUS Distance
------ ------ ------------------
Colour Color 0.0333333333333333
B. Compare Jaro-Winkler distance for strings with different prefixes
The following example compares pairs of words that have the same edit distance but different Jaro-Winkler distance values. Jaro-Winkler gives more preference to strings that match from the beginning.
SELECT Source,
Target,
EDIT_DISTANCE(Source, Target) AS EditDistance,
JARO_WINKLER_DISTANCE(Source, Target) AS JaroWinklerDistance
FROM (VALUES ('DWAYNE', 'DUANE'),
('CRATE', 'TRACE')
) AS compare(Source, Target);
Returns:
Source Target EditDistance JaroWinklerDistance
------ ------ ------------ -------------------
DWAYNE DUANE 2 0.16
CRATE TRACE 2 0.266666666666667
For more examples, see the Examples section in the Fuzzy string matching overview.