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 |
|
MiaF
Starting Member
13 Posts |
Posted - 2007-03-09 : 14:13:00
|
| I don't know how to title my question. What I want to do is the following:I have two tablesCustomer:ID Name1 John2 MaryPurchase:ID Customer Item1 1 book2 2 shoes3 1 pencilIs there a query I can write to get a result like this:Customer PurchaseJohn book pencilMary shoesThanks ahead for any idea. |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-03-09 : 16:36:24
|
| There is a T-SQL solution herehttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53293and if you want to get into CLR programming (2005 only) then there is a CLR user-defined concatenate aggregate function herehttp://msdn2.microsoft.com/en-us/library/ms254508.aspx |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-03-10 : 05:23:19
|
| try thisDeclare @strValue VarChar(1000)Select Id, @StrValue = Case When @strValue Is Null Then Item Else @strValue + ', ' + Item End From <Ur Table>Group By IdSelect Id, @strValue As ItemU can use COALESCE function also to do so.let me know,Mahesh |
 |
|
|
|
|
|