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 |
|
rubs_65
Posting Yak Master
144 Posts |
Posted - 2010-04-28 : 13:57:08
|
| Hi,We have a table with 2 columns and following sample data:COLA COLB1 1002 1011 1023 1043 1053 1063 100We need to get the output like:Result1 100|1012 1013 104|105|106|100Currently we are using cursor for each COLA go over list of COLB values and add pipe to separate values, Can we do this in query without using cursor and loop. |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-04-28 : 14:37:31
|
| [code]SELECT COLA, (SELECT COLB+'|' FROM table WHERE COLA=D.COLA FOR XML PATH('')) AS ListFROM (SELECT DISTINCT COLA FROM table)D[/code] |
 |
|
|
|
|
|