• Alternatively, using a Tally table (see link in my sig) to avoid the loop:

    declare @x nvarchar(100)

    set @x = 'AZ az' + char(160) + '01' -- note: 160 is an html non breaking space

    SELECT

    SUBSTRING(@x,N,1), ASCII(SUBSTRING(@x,N,1))

    FROM

    Tally

    WHERE

    N <= LEN(@x)