Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SqlNewBee123
Starting Member
1 Post |
Posted - 2007-05-25 : 16:14:37
|
| Dear All,I need to create a query to list all the subfolders within a folder.I have a database table that lists the usual properties of each of the folder.I have another database table that has two columns1. Parent folder2. Child folderBut this table maintains the parent child relationship only to one level.For example if i have a folder X that has a subfolder Y and Z.And Y has subfolders A and B.and B has subfolder C and Dand C has subfolder E and FThe database table will look likeparentfolder child folderX YX ZY AY BB CB DC EC FI want to write a query which will take a folder name as the input and will provide me a list of all the folders and subfolders under it. The query should be based on the table (parent - child) and there should not be any restriction on the subfolder levels to search and report for.I have been banging my head to do this but i have failed so far. Any help on this will be highly appreciated. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-25 : 16:20:07
|
| if you're using SQL SErver 2005 you can use CTE's = common table expression for this.google has many examples.if not then read this article:http://www.sqlteam.com/item.asp?ItemID=8866_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
|
|
|
|
|