• since there is only one column, why is this working as well ?

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

    ,@comma = ','

    FROM #a a

    ORDER BY 2

    Result : A,A,B,B,C,C

    rajesh.subramanian (6/25/2010)


    Good Question.

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

    ,@comma = ','

    FROM #a a

    ORDER BY 1

    Result : C

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

    ,@comma = ','

    FROM #a a

    ORDER BY a.a

    Result : A,A,B,B,C,C

    changing the order by giving different result...experts please explain?