select t.EntityID, t.AttributeID, stuff(x.Options, 1 , 1 , '') Options from ( select EntityID, AttributeID from @YourTable group by EntityID, AttributeID ) t cross apply ( select ',' + OptionText from @YourTable where EntityID = t.EntityID and AttributeID = t.AttributeID for xml path('') ) x(Options);If this does not help much then you can try using the dynamic pivot first and then the normal concat to derive your delimited lists (one for each combination). This will make the query much more complex, but considerably cheaper and probably faster. Please let me know if you want it and I can post a sample.
No one has followed this question yet.