• the XML solution can also be:

    select replace(

    convert(

    varchar(max),

    (select name+',' as [text()] from fruit order by id for xml path(''))

    )+',,,'

    ,',,,,'

    ,'')

    or, if there is no need in deleting the last comma and converting the result from xml to string, just

    select name+',' as [text()] from fruit order by id for xml path('')