Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Loop-select - combine multiple rows

$
0
0

Hi,

I have a table that looks like this:

IdParentIdPathLevel
AS-01NULLroot0
LM-01AS-01LM-011
PK-31LM-01http://myurl2
LK-65LM-01http://mysecondurl2
KL-46LK-65/ICT3
TR-73KL-46/Network4
PS-09KL-46/Admin4
MQ-71LK-65/HR3
OQ-46MQ-71/Recruitment4
OD-94TR-73/List5
MZ-67OD-94/item-1236

How can I get a result like this? Important, I only need to start from "http://myurl", ID = PK-31, level = 2?

I need to create a new column with the fullpath of the url.

IdParentIdPathLevelFullPath
PK-31LM-01http://myurl2http://myurl
KL-46LK-65/ICT3http://myurl/ICT
TR-73KL-46/Network4http://myurl/ICT/Network
PS-09KL-46/Admin4http://myurl/ICT/Admin
MQ-71LK-65/HR3http://myurl/HR
OQ-46MQ-71/Recruitment4http://myurl/HR/Recruitment
OD-94TR-73/List5http://myurl/ICT/Network/List
MZ-67OD-94/Item-1236http://myurl/ICT/Network/List/Item-123

Or is this not possible?


Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>