|
Posted by candide_sh on 10/31/07 11:40
Well, I knew I had read something about it but where? NOW I found it,
maybe from sqlservercentral.com, don't know the author, but it works
and is a straight solution.
thx for your answers
candide_sh
>>>>>>>>>>>>>>>
It helps you in situaions whenever you wish to create commm seperated
values actually originating from multiple records. Say, your query
return three records in folloing patter:
Student_Name
=============
Ricky
Adam
Mathew
But, say you wish to have records in following patter:
Student_Name
============
Ricky, Adam, Mathew
That is how it works. Try it...I beleive it will help you a lot
create procedure sp_return_students
as
set nocount off
/* Declare variable which will store all student name */
Declare @StudentName varchar(8000)
/* Query that will return student names and at the same time
concatenate values. /*
select @StudentName = coalesce(@StudentName + ', ', '') + stu_name
from tbl_students
/* At last, you just have to define column name that will store values
*/
Select @StudentName As Student_Name
>>>>>>>>>>>>>>>
[Back to original message]
|