I'd like to flatten a table of customers and products into list of customers and a corresponding comma separated list of products.
It's in SQL server and I know I can write a simple c# program to do this but I'd prefer a straight tsql solution.
I'm starting like this:
Customer Product
Joe Product1
Joe Product2
Jim Product1
Jill Product3
Jill Product4
And I want to end up like this:
Customer Products
Joe Product1,Product2
Jim Product1
Jill Product3, Product4
I don't want to use PIVOT because I don't want to hard code the productIDs. I'd prefer not to use cursors but if that's the only way I suppose it's better than mixing c# and TSQL.