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 2000 Forums
 Transact-SQL (2000)
 How do I gat a sub query to return as a list

Author  Topic 

colski
Starting Member

4 Posts

Posted - 2003-02-09 : 10:59:43
I want to be able to have one of the columns of my query returning a list of ID's associated with each row.

I have seen several snippets of SQL that show how to return a list but as far as I can see they would not work as a sub query.

Please tell me how I can get around this.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-02-09 : 11:56:00
Can you provide some more background on why you need it as a subquery? I can see why you want it as EITHER a list or a subquery, but not both (to me it defeats the purpose) If you have any SQL statements you're using now and the structure of the tables you're using it would be immensely helpful if you could post them.

Go to Top of Page

colski
Starting Member

4 Posts

Posted - 2003-02-10 : 04:59:34
I have two tables:

Tasks:
-task_id
-task_summary

Dependencies:
-parent_task_id
-child_task_id

What I want to achieve is to pull out all the tasks with the ID's of each tasks children as a list.

Something like:

task_id | task_summary | children
---------------------------------------------
1 Go to work 2,3,4
2 Turn on computer
3 Ask SQL question
4 Get my problems solved 5
5 Go home happy


Go to Top of Page

colski
Starting Member

4 Posts

Posted - 2003-02-10 : 05:03:25
quote:

I have two tables:

Tasks:
-task_id
-task_summary

Dependencies:
-parent_task_id
-child_task_id

What I want to achieve is to pull out all the tasks with the ID's of each tasks children as a list.

Something like:

task_id | task_summary | children
----------------------------------------------
1 | Go to work | 2,3,4
2 | Turn on computer |
3 | Ask SQL question |
4 | Get my problems solved | 5
5 | Go home happy |






My ultimate reason for wanting the results like this is to display a matrix of task dependencies using a HTML table.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-02-10 : 07:50:13
Have you looked at any of the CSV building articles yet?

http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-02-10 : 16:56:22
As always, I like to reference:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=19647

Byrmol's function a few posts in might be just what the doctor ordered for you.



- Jeff
Go to Top of Page
   

- Advertisement -