• I'm not sure why DISTINCT was required here..

    SELECT @t = @t + @comma + a.a ,@comma = ','

    FROM #a a ORDER BY 1

    The above select returns a C as well. Am I missing something here?