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 |
|
stephe40
Posting Yak Master
218 Posts |
Posted - 2006-08-18 : 10:58:32
|
| I sure I am not the first person to ask this, for that I apologize, but I can not find anything in the search.Given the following data:key data1 A1 B1 C2 A2 CWhat is the best way to get the data back like this:key data1 A, B, C2 A, CAll the ideas I am coming up with require hard coding the key id's somewhere.- Eric |
|
|
stephe40
Posting Yak Master
218 Posts |
Posted - 2006-08-18 : 11:01:03
|
| I just realized I could use a UDF that given an ID would return the right string of stuff. Is there a built in way?- Eric |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-08-18 : 11:31:56
|
| UDF is the simplest - could probably use a CTE in v2005.the UDF would bedeclare @s varchar(1000)select @s = coalesce(@s + ',',data)from tblwhere key = @key==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|