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 |
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2009-04-18 : 11:48:31
|
Hi, I need help please. I have one column whith different values depending on result. I would like to return a one row string result with a comma seperating the values.The column output as follows:Column A--------123I would like to output as 1, 2, 3Please Assist. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-18 : 15:30:15
|
[code]DECLARE @Str varchar(8000)SELECT @Str=COALESCE(@Str,'') + CAST(ColA as varchar(10)) + ','FROM YourTableSELECT @Str[/code] |
|
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2009-04-20 : 09:48:04
|
Thank You very much, exactly what i needed. Searched long and hard.How do i remove the "," at the end?eg: Test1,Test2,Test3,Regards |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-04-20 : 09:51:16
|
DECLARE @Str varchar(8000)SELECT @Str=COALESCE(@Str,'') + CAST(ColA as varchar(10)) + ','FROM YourTableSELECT LEFT(@Str,LEN(@str)-1) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-20 : 09:59:12
|
Try this tooDECLARE @Str varchar(8000)SELECT @Str=COALESCE(@Str+',','') + CAST(ColA as varchar(10)) FROM YourTableSELECT @StrMadhivananFailing to plan is Planning to fail |
|
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2009-04-20 : 10:09:13
|
Great Suff - Thank You All :) |
|
|
|
|
|
|
|