Reply to Re: get some rows into one column

Your name:

Reply:


Posted by Gert-Jan Strik on 10/31/07 17:36

candide_sh,

There is one major problem with this solution: it might not work. It
might not work the next time you run it, after you have run a service
pack, after you have upgraded your server, after you have added another
join to your query, etc. And that is because there is no defined
behavior for this concatenation if multiple rows are involved.

So I would seriously advise you NOT to do it this way.

--
Gert-Jan


candide_sh@yahoo.de wrote:
>
> 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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация