I'm trying to use the below query into HPALM.
However this is a Oracle syntax and I need to translate it to SQL Server.
Indeed, SYS_CONNECT_BY_PATH is an Oracle feature.
SELECT ls_father_id,ls_id,substr(SYS_CONNECT_BY_PATH(ls_name,'\'),2) "Path"
FROM lists
START WITH ls_name in (select ls_name from lists where ls_father_id = 0)
CONNECT BY PRIOR ls_id=ls_father_id
It is it possible to translate it? If yes, how to do?
Thank you
You can use recursive CTE for this (in Oracle also), so you can check it first in your current Oracle database.
Example below
LS_ID | LS_FATHER_ID | LS_NAME | PATH_ ----: | -----------: | :------ | :------------- 1 | 0 | aaa | aaa 2 | 1 | bb | aaa\bb 3 | 0 | c | c 4 | 2 | cca | aaa\bb\cca 5 | 4 | vvv | aaa\bb\cca\vvv 6 | 3 | f | c\f 7 | 1 | ee | aaa\eeLS_ID | LS_FATHER_ID | PATH_ ----: | -----------: | :------------- 1 | 0 | aaa 2 | 1 | aaa\bb 3 | 0 | c 4 | 2 | aaa\bb\cca 5 | 4 | aaa\bb\cca\vvv 6 | 3 | c\f 7 | 1 | aaa\eedb<>fiddle here