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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Retrieving hierarchical data

Author  Topic 

de4ever@gmail.com
Starting Member

36 Posts

Posted - 2009-05-05 : 01:43:47
i have two tables foldertab and doctab
foldertab
---------

folderid parentfolderid
1 null
2 1
3 2
4 2

doctab
------
docid folderid
1 4
2 2
3 4

I want to retrieve all documents from all child folder by providing a folderid

Please help me out

thanks



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-05 : 01:47:47
You can start by reading Books Online. Start with the chapter Common Table Expressions (CTE).
There are examples of recursive common table expressions too.
Good luck.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

de4ever@gmail.com
Starting Member

36 Posts

Posted - 2009-05-05 : 01:55:47
quote:
Originally posted by Peso

You can start by reading Books Online. Start with the chapter Common Table Expressions (CTE).
There are examples of recursive common table expressions too.
Good luck.



E 12°55'05.63"
N 56°04'39.26"




Sorry mate , i don't have enough time to go through books.any way thanks for ur suggestion
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-05 : 02:03:48
What do you mean "Don't have the time"?
Do you expect us to do your work for you? What happens when your manager wants to change the code we suggest to you? Do you plan to ask here again?
When do you have time to learn and study the suggestion we make for you?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

de4ever@gmail.com
Starting Member

36 Posts

Posted - 2009-05-05 : 02:19:22
quote:
Originally posted by Peso

What do you mean "Don't have the time"?
Do you expect us to do your work for you? What happens when your manager wants to change the code we suggest to you? Do you plan to ask here again?
When do you have time to learn and study the suggestion we make for you?


E 12°55'05.63"
N 56°04'39.26"



i am not good in sql and i did not understand that cte that's why i posted it here after doing my r& d.so that some technically sound specialist professional can help me out of the problem.there is nothing personal abt it...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-05 : 04:36:03
I understand and wish you all the best!



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -