no need of looping. this is called crosstabing and can be done efficiently using set based techniquesSomething like below should work (this is just a stub to start with as I dont have any info on your table columns, sample data etc)SELECT p.ProductID,p.ProductName,MAX(CASE WHEN Seq=1 THEN ins.InsuranceDescription END) AS Insurance1,MAX(CASE WHEN Seq=1 THEN prm.PremiumInsuranceDescription END) AS PremiumIns1,MAX(CASE WHEN Seq=2 THEN ins.InsuranceDescription END) AS Insurance2,MAX(CASE WHEN Seq=2 THEN prm.PremiumInsuranceDescription END) AS PremiumIns2,...FROM(SELECT *,ROW_NUMBER() OVER (PARTITION BY ProductID ORDER BY ItemID) AS Seq, FROM tblProducts p INNER JOIN tblProductItems pi ON pi.ProductID = p.ProductID INNER JOIN tblItem i ON i.IetmID = pi.ItemID LEFT JOIN tblInsurance ins ON ins.InsuranceID = i.InsuranceID LEFT JOIN tblpremium prm ON prm.PremiumInsuranceID = i.PremiumInsuranceID WHERE p.Vendor= @YourVendor)tGROUP BY p.ProductID,p.ProductName
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/