Blog

Thirteenth Parallel

18 January 2005

It’s crazy to think that it was three years and five days ago that we released the first issue of "Thirteenth Parallel", an "e-zine" about web technologies. We only managed to run 7 issues before we found we didn’t have enough time to keep up with the monthly releases. However, even long after that we had big ideas about what we wanted to do with the project, and even started on several occasions to build a new site. Time is still a big problem for us, but I have finally gotten round to putting the articles back online in a simple, quick interface.

Levenshtein Distance in SQL Server

11 January 2005

Merry Christmas, Happy New Year, and all that. This is a kind of dull post but I know some people who come here will find it useful:

I have found an implementation of the Levenshtein distance function in TSQL. This allows you to calculate the similarity between two strings, which is particularly useful for searching features. You will also need a simple user-defined function called MIN3 that is not listed at the above link, here’s the super quick one I wrote:

1   CREATE function Min3( @a int, @b int, @c int ) returns int AS
2   BEGIN
3   	DECLARE @Retval int
4   	if @a <= @b AND @a <= @c
5   		BEGIN
6   		SET @Retval = @a
7   		END
8   	if @b < @a AND @b <= @c
9   		BEGIN
10  		SET @Retval = @b
11  		END
12  	if @c < @a AND @c < @b
13  		BEGIN
14  		SET @Retval = @c
15  		END
16  RETURN @Retval
17  END