• unComplicate:

    create table #tmp (x nvarchar(max))

    declare @s-2 nvarchar(max) = 'a,1,2,x,3,4,z'

    declare @aux nvarchar(max)

    while charindex(',',@s) > 0

    begin

    set @aux = substring(@s,0,charindex(',',@s))

    SET @s-2 = LTRIM(STUFF(@s,1,len(@aux)+1,''))

    insert into #tmp select @aux

    end

    insert into #tmp select @s-2

    select x from #tmp

    drop table #tmp