On MS SQL Server 2008, how do I make a select statement, that joins two tables, and return the content of table 2 as a comma-separated list?
Example: Table 1 contains all my orders, and table 2 my order lines. I want to select all fields from orders, as well as a comma separated list of all fields from the corresponding order lines, with each order line separated by semicolon (or something else).
So something like this:
| Orders.custno | Orders.name | Orders.email | Orders.phone | Order lines |
|---------------|-------------|------------------|--------------|---------------------------------------------------------------------|
| 123456 | Dave | dave@example.com | 1234567890 | “112233”,”Running shoes”,”495.00”;”223344”,”Roller blades”,”699.00” |
Hope this makes sense.
Thanks.