homepage Welcome to WebmasterWorld Guest from 54.234.128.25
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
Building a tree from individual file paths in T-SQL
digitalv




msg:4211344
 2:34 am on Oct 5, 2010 (gmt 0)

Usually I'm the one answering database questions, but I'm completely stumped here. Looking for some T-SQL code to get the results I need.

I have a table that contains a couple of file paths, lets say the table is called FOLDERS and the field name is FOLDER. Some results would be:

C:\inetpub\custerr\en-US\
C:\inetpub\history\CFGHISTORY_0000000001\
C:\RIPPED\
C:\Users\Owner\Desktop\
C:\Users\Owner\Documents\Bar128\
C:\Users\Owner\Documents\BlackBerry\Backup\

etc.

Basically what I need to do is figure out how to select these in such a way that I can build a collapsible folder tree in an application. So my results would need to be something like:

c:\
c:\inetpub
c:\inetpub\custerr
c:\inetpub\custerr\en-US\
c:\inetpub\history\
C:\inetpub\history\CFGHISTORY_0000000001\
C:\RIPPED
C:\Users
C:\Users\Owner
C:\Users\Owner\Desktop
C:\Users\Owner\Documents
C:\Users\Owner\Documents\Bar128
C:\Users\Owner\Documents\BlackBerry
C:\Users\Owner\Documents\BlackBerry\Backup

Anyone have any ideas? I know I could do this using a temp table and a cursor, but I'm wondering if there is a more efficient way first.

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved