• This doesn't answer the question directly, but hopefully it helps you come up with a solution.

    with rCTE as (

    select

    ag.id,

    ag.catlevel,

    ag.slug_nl,

    CatString = cast(ag.slug_nl as nvarchar(max)),

    SortKey = cast(ag.id as varbinary(max))

    from

    [dbo].[articlegroups] ag

    where

    ag.parentid = 0

    union all

    select

    ag.id,

    ag.catlevel,

    ag.slug_nl,

    CatString = r.CatString + N' > ' + ag.slug_nl,

    SortKey = r.SortKey + cast(ag.id as varbinary(max))

    from

    rCTE r

    inner join [dbo].[articlegroups] ag

    on (r.id = ag.parentid)

    )

    select * from rCTE order by SortKey;