I have a SQL Server DB that has a table of products, and another table which contains a list of the sku variants of each product if it has one.
I want to export all the products and their SKU's into excel. At the moment, I have a helper SQL function which performs the subquery against a product_id and concatenates all the SKU's into a comma-delimited string, e.g:
Product Code, Name, SKUs
111 P1 77, 22, 11
Is there an easier way to do this, so that each SKU is a row which the associated product code as well, i.e:
Product Code, Name, SKUs
111 P1 77
111 P1 22
111 P1 11