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
 General SQL Server Forums
 New to SQL Server Programming
 Return Multiple

Author  Topic 

adam_bris
Starting Member

2 Posts

Posted - 2008-06-25 : 20:25:31
Hi
I have two tables linked by CallID with a one (Call) to many (Assignments) relationship.
I would like to create a User Defined Funct. to display all the assignments of a call in one string, separated by carriage retn.
For example, if CallID 12345 has assignments A and B, I would like to have them return as:
A
B
The purpose of this is to have them displayed in a report.
I have absolutely no idea if this is possible or how to go about it. Thankyou very much to anyone that can assist.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-25 : 21:49:03
[code]
select a.assignment
from assignments_table a
where a.CallID = 12345
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

adam_bris
Starting Member

2 Posts

Posted - 2008-06-25 : 22:11:07
Thanks khtan,

If I was to then report on that however, it would only return the first assignment.
I would like to return all assignments in one string, separated by carriage return.


Adam
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-25 : 22:17:45
see
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254
http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/rowset-string-concatenation-which-method-is-best.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -