I have the following product data (for an online shop):
ProductId ProductOptionGroupId ProductOptionId
26 1 13
26 1 12
44 1 22
44 1 23
44 2 20
44 2 21
44 3 25
44 3 24
Where a ProductOptionGroup would be (say) "Size" or "Colour", and the ProductOption would be (say) "Large", "Extra Large" and "Red", "Black" etc.
Basically, I want to find all possible product option combinations for each product. For example, for product 44, I'd want:
22, 20, 25 (Large, Black, Cotton)
22, 20, 24 (Large, Black, Nylon)
22, 21, 25 (Large, Red, Cotton)
22, 21, 24 (Large, Red, Nylon)
23, 20, 25 (Extra Large, Black, Cotton)
23, 20, 24 etc...
23, 21, 25
23, 21, 24
Only one product option from each product option group for each row. I.e. Large and Extra large are mutually exclusive.
Ideally, I'd like these values concatenated into a single VARCHAR for each product ("22,21,25" etc).
How can this be achieved in SQL Server 2005?
Thanks