I have a loop built which selects groups of records out based on different product groups.
The results are returned as XML which is then updated against the product group in a master product group table.
This is fine but now the product list is growing fast, the loop loops 100's of times and it's taking minutes to run now.
is there a way I can write this as a single update?
declare @products_xml xml
while @group_id is not nul
set @products_xml =
SELECT id, name, price
WHERE product_group = @group_id
FOR XML RAW ('Product'), ROOT ('Product_Group');
update product_group set products_xml = @products_xml
--get next @groupid
any help welcome,