hi
hope this helps
i was able to get the output
but i have to make changes to your input data format
. i had to make it uniform and consistent
i also had to add an identity column for row identification purpose
; with cte as
(
SELECT
ROW_NUMBER() over( partition by rn123 order by id ) as rn , rn123,value
FROM #test
cross apply
string_split(ID,'/')
) , cte_2 as
(
select string_agg(cast(rn as varchar) +'*'+value,'/')as ID from cte group by rn123
)
select
SUBSTRING(ID, charindex('1*',ID)+2,charindex('2*',ID) - charindex('1*',ID)-3) ,
SUBSTRING(ID, charindex('2*',ID)+2,charindex('3*',ID) - charindex('2*',ID)-3) ,
SUBSTRING(ID, charindex('3*',ID)+2,charindex('4*',ID) - charindex('3*',ID)-3) ,
SUBSTRING(ID, charindex('4*',ID)+2,charindex('5*',ID) - charindex('4*',ID)-3) ,
SUBSTRING(ID, charindex('5*',ID)+2,charindex('6*',ID) - charindex('5*',ID)-3) ,
SUBSTRING(ID, charindex('6*',ID)+2,charindex('7*',ID) - charindex('6*',ID)-3)
from cte_2