If given a table like this
Group Value
Item 1 A
Item 1 B
Item 1 C
Item 1 D
Item 2 Z
Item 2 Y
Item 2 X
Item 2 W
I would like a result in a table like this
Group
Item 1 A|B|C|D
Item 2 Z|Y|X|W
Now I know how to do an individual group.
SELECT @Item1= ISNULL(@Item1+ '|', '') + CodeValue
FROM Codes
WHERE CodeType = 'Item 1'
I guess I can put that in a loop. My question is there a more elegant way?