Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Concatenation of hierarchal data
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

57 Posts

Posted - 01/28/2013 :  08:23:35  Show Profile  Reply with Quote
I have hierarchal data that looks like below with parent/child relationships defined.

Item,ID, ParentID
CEO, 1, null
CIO, 2, 1
COO, 3, 1
VP of Dev, 4, 2
VP of Infrastructure, 5, 2
VP of Marketing, 6, 3
VP of Support, 7, 2
VP of Sales, 8, 3
Sales Executive 1, 9, 8
Sales Executive 2, 10, 8
Marketing Executive 1, 11, 6
Marketing Executive 2, 12, 6
Dev Executive 1, 13, 4
Dev Executive 2, 14, 4

I want to return the following:
Item,ID, ParentID
CEO, 1, null,CEO
VP of Dev, 4, 2,CEO.COO.VP of Dev
VP of Infrastructure, 5, 2, CEO.COO.VP of Infrastructure
VP of Marketing, 6, 3, CEO.COO.VP of Marketing
VP of Support, 7, 2, CEO.COO.VP of Support
VP of Sales, 8, 3,CEO.COO.VP of Sales
Sales Executive 1, 9, 8, CEO.COO.VP of Sales.Sales Executive 1

and so on... where the new column is the full "Dot" notation

I need some kind of recursive query. Thanks in advance!


Edited by - boggyboy on 01/28/2013 08:36:25

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 01/28/2013 :  08:38:28  Show Profile  Reply with Quote
see same scenario discussed here

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000