| 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.
|
|