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 |
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-02-04 : 10:48:38
|
| Hi GuysI have a table/view with the following data:ReceiptID, SKU, ProductDescription11277922, SAHAE410208, Laura Lees Ruffle Edge Dress 11277922, IBIUN162836, Braza Seam Free Invisible Bandeau11277922, SAHAE447830, Happie Loves It Stripe Cotton Dress11277922, QAHAE339840, Peoples Market Jersey DressIs it possible in SQL to produce a query that returns all details in one row?Eg:127792, “SAHAE410208 Laura Lees Ruffle Edge Dress”,” IBIUN162836 Braza Seam Free Invisible Bandeau”,” SAHAE447830 Happie Loves It Stripe Cotton Dress”,” QAHAE339840 Peoples Market Jersey Dress” |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-04 : 10:55:00
|
yup its possibleSELECT DISTINCT t.ReceiptID,STUFF((SELECT ',' + '"'+ SKU + '"' + ',' + '"'+ ProductDescription + '"' FROM Table WHERE ReceiptID=t.ReceiptID FOR XML PATH('')),1,1,'') AS ValueFROM Table t |
 |
|
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-02-04 : 11:06:32
|
| Thank you as always visakh |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-02-04 : 11:14:37
|
| why the heck are you trying to do that? imagine if your table has 10million rows. just trying to understand the reason why. |
 |
|
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-02-04 : 11:22:36
|
| Its just for reporting purposes. There won't be that many rows as the data is only for 1 day. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-04 : 12:10:01
|
quote: Originally posted by rcr69er Thank you as always visakh
you're welcome as always |
 |
|
|
|
|
|
|
|