This could be done relatively easy with recursive common table expressions:
with cte as (
select
T1.TopicID, T1.Code, T1.Name, T1.ParentID,
T1.ParentID as NewParentID,
cast(T1.Code as nvarchar(max)) as NewColumn
from Table1 as T1
where not exists (select * from Table1 as T2 where T2.ParentID = T1.TopicID)
union all
select
c.TopicID, c.Code, c.Name, c.ParentID,
T1.ParentID as NewParentID,
c.NewColumn + cast(T1.Code as nvarchar(max)) as NewColumn
from cte as c
inner join Table1 as T1 on T1.TopicID = c.NewParentID
)
select
c.TopicID, c.Code, c.Name, c.ParentID, c.NewColumn
from cte as c
where c.NewParentID = 0