I have a problem in SQL Server 2000. I cannot send a recursive WITH
query because CTE was introduced in SQL Server 2005.
My question is the following:
how can I retrieve the answer of a hierarchy if I do not want to use a procedure but I can send 2 queries in which case I can include the answer of the first query in the second.
This is the query for SQL Server 2005:
WITH recursive_back (SOACTION,SOACTIONS) AS
(SELECT child.SOACTION,child.SOACTIONS
FROM soaction child
WHERE child.soaction ={id to search}
UNION ALL
SELECT parent.SOACTION,parent.SOACTIONS
FROM recursive_back child,soaction parent
WHERE child.soactions = parent.soaction ),
recursive_ahead (SOACTION,SOACTIONS) AS
(SELECT parent.SOACTION, parent.SOACTIONS
FROM soaction parent,recursive_back
WHERE parent.soaction=recursive_back.soaction
UNION ALL
SELECT child.SOACTION, child.SOACTIONS
FROM recursive_ahead parent, soaction child
WHERE child.soactions = parent.soaction)
SELECT R.SOACTION,R.SOACTIONS
FROM recursive_back R, SOACTION A
WHERE R.SOACTION=A.SOACTION
UNION
SELECT R.SOACTION,R.SOACTIONS
FROM recursive_ahead R, SOACTION A
WHERE R.SOACTION=A.SOACTION;
GO