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.
| Author |
Topic |
|
atulkukreja
Starting Member
13 Posts |
Posted - 2004-09-01 : 09:16:16
|
| I have a single column table with 10 rows.I want to return a single string with the value in each row concatenated with a space or comma as a delimiter.Example:Select fName from FriendfName------John DoeJim JohnsonDeepa Patel----Desired result:John Doe, Jim Johnson, Deepa Patel, .....Thanks. |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-01 : 09:25:12
|
| [code]Declare @list varchar(1000)Declare @myTable table (fname varchar(100))Insert Into @myTableSelect 'Corey Aldebol'Union All Select 'Bill Gates'Union All Select 'George Washington'Union All Select 'Henry Ford'Union All Select 'Heidi Klum'Select @list = isnull(@list+',','') + fName From @myTableSelect @list[/code]Corey |
 |
|
|
raymondpeacock
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-09-01 : 09:28:19
|
| Or use COALESCESelect @list = COALESCE(@list + ',' + fname, fname) From @myTableRaymond |
 |
|
|
|
|
|