i'm trying to concatenate the values from a column from all levels of a certain path
this is my sql:
WITH
hi as (
select c.id id, cast(c.code as nvarchar) code, c.title, c.parent from CaseTypes c
where c.parent is null
union all
select c.id, cast((h.code + c.code ) as nvarchar) code , c.title, c.parent from CaseTypes c
inner join hi h on c.parent = h.id
)
select * from hi
the problem is that only the first level (where parent is null) is taken, the rest isn't