Mark;
Thanks for the tip! I was able to get the code you sent to execute on my
SQL7 box but did not solve the problem.
What happened is this: I wrote a stored procedure that would select a bunch
of details about a task, and then I would try to COALESCE the names of users
associated with the task from another table as a subquery within the select
statement. The SP would return an error stating I could not use coalesce in
a query which returned data (WTF?).
The query (in one of its incarnations) looked something like this:
DECLARE @users varchar(255)
DECLARE @project_id int
SELECT task_id,
(SELECT @users = COALESCE(user_id, ', ','') + CAST(user_id AS varchar(10))
FROM tbl_users tu JOIN ref_task_assignment rta
ON tu.user_id = rta.user_id
WHERE rta.task_id = tt.task_id
)
FROM tbl_tasks tt
WHERE project_id = @project_id
RETURN
I played around with the syntax for a while, but no go.
Eventually, I ended up writing a cursor to build the query, setting the
value of @users prior to running the real query. This was murderously slow
and I ended up just grouping my output in CF.
Just wondering if anyone can see something I did wrong with the subquery.
This technique could really be useful if I could get it to go.
M
-----Original Message-----
From: Mark W. Breneman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 5:26 PM
To: CF-Talk
Subject: RE: Return a Sub-Query as a Comma Delimited List
You may want to look at this
http://www.sqlteam.com/item.asp?ItemID=2368
I tried this a few weeks ago. Seems that it needs to be a stored procedure
to run. I was looking for a solution that involved a simple query. But, it
may help you.
Mark W. Breneman
-Macromedia Certified ColdFusion Developer
-Network / Web Server Administrator
Vivid Media
[EMAIL PROTECTED]
www.vividmedia.com
608.270.9770
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm