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

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

boggyboy
Yak Posting Veteran

USA
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
CIO, 2, 1,CEO.CIO
COO, 3, 1,CEO.COO
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!

Meghan

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

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 01/28/2013 :  08:38:28  Show Profile  Reply with Quote
see same scenario discussed here
http://msdn.microsoft.com/en-us/library/ms186243(v=sql.105).aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.12 seconds. Powered By: Snitz Forums 2000