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 |
|
cindylee
Yak Posting Veteran
55 Posts |
Posted - 2007-04-11 : 21:32:25
|
| Hi ppl,I would like to display a distinct columns in table in row format.Ex:col11568944like to display in the following format:1,5,6,8,9,44anyhelp much appreciatedC |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-12 : 07:37:22
|
| Also, if you use front end application, do concatenation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-04-12 : 11:17:56
|
quote: Originally posted by cindylee Hi ppl,I would like to display a distinct columns in table in row format.Ex:col11568944like to display in the following format:1,5,6,8,9,44anyhelp much appreciatedC
try this with case stmt ...DECLARE @STR VARCHAR(1000)SELECT @STR = (CASE WHEN @STR IS NULL THEN <ur field> ELSE @STR + ', ' + <ur field> END)FROM <ur table>SELECT @STR AS CSV_STRINGMahesh |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|