Home All Groups Group Topic Archive Search About

How to select a single varchar combined by many rows?

Author
15 Sep 2006 3:09 AM
Cylix
This question is quite common in my query, but I still have no idea
about that.

For example,
My client have a number of companies, each company has its own phone
number.
Each phone number is store in row(not fixed number of row).

Let say, there are 4 phone number (row) as
852 3745 3844
86 1235 4578
88 481 2356 759
97 124 457 4134

How can I select a single cell like "852 3745 3844, 86 1235 4578, 88
481 2356 759, 97 124 457 4134"

OR Select it as single row with four columns?

Thank you.

Author
15 Sep 2006 3:47 AM
Aaron Bertrand [SQL Server MVP]
Why can't the presentation tier do this?
http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-single-row.html



Show quote
"Cylix" <cylix2***@gmail.com> wrote in message
news:1158289745.966655.151410@p79g2000cwp.googlegroups.com...
> This question is quite common in my query, but I still have no idea
> about that.
>
> For example,
> My client have a number of companies, each company has its own phone
> number.
> Each phone number is store in row(not fixed number of row).
>
> Let say, there are 4 phone number (row) as
> 852 3745 3844
> 86 1235 4578
> 88 481 2356 759
> 97 124 457 4134
>
> How can I select a single cell like "852 3745 3844, 86 1235 4578, 88
> 481 2356 759, 97 124 457 4134"
>
> OR Select it as single row with four columns?
>
> Thank you.
>
Author
15 Sep 2006 4:36 AM
Cylix
Thanks Aaron,
The SQL is really interest and advance for me.
It do really help.
Author
15 Sep 2006 7:20 AM
SQL Ken
Cylix wrote:
Show quote
> This question is quite common in my query, but I still have no idea
> about that.
>
> For example,
> My client have a number of companies, each company has its own phone
> number.
> Each phone number is store in row(not fixed number of row).
>
> Let say, there are 4 phone number (row) as
> 852 3745 3844
> 86 1235 4578
> 88 481 2356 759
> 97 124 457 4134
>
> How can I select a single cell like "852 3745 3844, 86 1235 4578, 88
> 481 2356 759, 97 124 457 4134"
>
> OR Select it as single row with four columns?
>
> Thank you.

AddThis Social Bookmark Button