• Thanks, interesting way of looking at the problem.

    Also you could change the WHERE clause to

    WHERE N <= DATALENGTH(CountryName) instead of using the SUBSTRING comparison.

    The example given in Books Online uses a WHILE loop for a similar problem.. It would be nice to know the real world speed differences in these 2 approaches for this particular dataset.

    SET TEXTSIZE 0

    SET NOCOUNT ON

    -- Create the variables for the current character string position

    -- and for the character string.

    DECLARE @position int, @string char(15)

    -- Initialize the variables.

    SET @position = 1

    SET @string = 'Du monde entier'

    WHILE @position <= DATALENGTH(@string)

    BEGIN

    SELECT ASCII(SUBSTRING(@string, @position, 1)),

    CHAR(ASCII(SUBSTRING(@string, @position, 1)))

    SET @position = @position + 1

    END

    SET NOCOUNT OFF

    GO