0

I have 2 tables:

Orders

order_id   order_total
----------------------
1          150
2          230

Items

order_id   item_number
-----------------------
1          abc
1          foo
2          123
2          bar
2          test

I'd like to join both tables and concatenate the item_number column, so the results will looks like this:

order_id    order_total    item_number_concat
---------------------------------------------
1           150            abc, foo
2           230            123, bar, test

What's a way to do this in SQL Server 2008?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Joe Defill
  • 439
  • 1
  • 4
  • 16
  • Why do you want to do this? SQL is not intended as a _presentation_ system. What is your presentation layer (e.g. WinForms, Reporting systems, PHP, ASP.NET, etc) and why can't you do it there instead? – Dai Nov 24 '21 at 03:28
  • Also, why on earth are you still running SQL Server 2008 today? Why can't you update to SQL Server 2017 or later? The Express edition is _free!_ (MSSQL 2017 has `CONCAT_WS` which is what you want, btw). – Dai Nov 24 '21 at 03:39

0 Answers0