A: 

I think your attempt differs from the code that you say works in that the working code orders by distance first, whether or not that is original or trimmed distance. Your attempt orders by original distance first, then trimmed.

I'm not sure I understand what you're trying to do entirely, but does the following do what you need?

SELECT TOP 1
    @ResultId = ID,
    @Result = [Name],
    @ResultDist = distOrig,
    @ResultTrimmed = distTrimmed
FROM (
    SELECT
        ID, [Name], 
        dbo.Levenshtein(@Source, [Name]) As distOrig,
        dbo.Levenshtein(@SourceTrimmed, [Name])) As distTrimmed,
        Frequency
    FROM MyTable
) AS T
ORDER BY
    CASE WHEN distOrig > distTrimmed THEN distOrig ELSE distTrimmed END, -- Distance
    CASE WHEN distOrig > distTrimmed THEN 1 ELSE 0 END,                  -- Trimmed
    Frequency                                                            -- Frequency
Paul
Yes, Worked great! Cut the time from over an hour to 8 minutes. Unfortunately it's a 700000 record table and although it's much much faster, running your SQL on that takes 8 minutes... I need it to be within a minute, at this point I'm not even sure if that's possible. Any more ideas on how to refine it futher?
Matt
If @Source is often equal to @SourceTrimmed, then you can avoid calling dbo.Levenshtein() twice. I'd run "SELECT dbo.Levenshtein(@Source, [Name]) FROM MyTable", and see how long that takes alone as a starting point. Failing that there may be a way of running the query just on rows that are likely to be near the top of the ORDER BY with some pre-processing
Paul
Yes I realized I should always be using @Source so that cut it down to 1 select which cut down the process time in half. Working on the second part now...
Matt