Convert Oracle SQL to Microsoft SQL Server - eliminate CONNECT BY PRIOR

37 views Asked by At

Can someone please show me how to replace CONNECT BY PRIOR in the following script? This may look familiar to some of you as I am trying to build a hierarchy from Maximo data.

SELECT
    lh.location,
    loc.description locdescription,
    assetnum,
    asset.description,
    LEVEL*8-1 ||'pt' pad
FROM
    lochierarchy_vw AS lh
JOIN
    locations_vw AS loc ON loc.location = lh.location
LEFT OUTER JOIN
    asset_vw AS asset ON asset.location = lh.location 
CONNECT BY PRIOR 
    lh.location=lh.parent 
START WITH
    lh.parent IS NULL

I've tried a form of recursive Select but could not get it correct.

0

There are 0 answers