• I have found using STUFF to create the output to be a little bit faster. I am assuming that it is due to traditional string concantination issues...

    ALTER FUNCTION hex2alpha( @input VARCHAR(256) ) RETURNS VARCHAR(256) AS
    BEGIN
        DECLARE @output VARCHAR(256); SET @output = SPACE(LEN(@input)/2)
    
        SELECT @output = STUFF(@output,a.dec+1,1,CHAR(b.dec))
        FROM 
            dec2hex AS a
            INNER JOIN dec2hex AS b ON b.hex = SUBSTRING(@input,a.dec*2+1,2)
        WHERE
            a.dec < LEN(@input)/2
        ORDER BY a.dec
    
        RETURN @output
    END