Help with a t-sql query

Posted by user324650 on Stack Overflow See other posts from Stack Overflow or by user324650
Published on 2010-04-27T21:28:03Z Indexed on 2010/04/27 21:43 UTC
Read the original article Hit count: 284

Filed under:
|
|
|

Hi

Based on the following table

Path
----------------------
area1
area1\area2
area1\area2\area3
area1\area2\area3\area4
area1\area2\area5
area1\area2\area6
area1\area7

Input to my stored procedure is areapath and no.of children (indicates the depth that needs to considered from the input areapath)

areapath=area1
children=2

Above should give

Path
-----------
area1
area1\area2
area1\area2\area3
area1\area2\area5
area1\area2\area6
area1\area7

similary for
areapath=area2 and children=1 output should be

Path
---------------
area1\area2
area1\area2\area3
area1\area2\area5
area1\area2\area6

I am confused how to write a query for this one.

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql