Jonathan I found a great example of this site
link
I have the following table:
Customer Product Code
1 Jorge piso
1 Jorge porta
1 Jorge faucet
I need the result of this select to look like this:
Customer Product Code
1 Jorge floor, door, faucet
- Concatenating
SELECT CODIGO,
CLIENTE,
COALESCE(
(SELECT CAST(PRODUTO AS VARCHAR(10)) + ';' AS [text()]
FROM TABELA AS O
WHERE O.CODIGO = C.CODIGO
and O.CLIENTE = C.CLIENTE
ORDER BY CODIGO
FOR XML PATH(''), TYPE).value('.[1]', 'VARCHAR(MAX)'), '') AS Produtos
FROM TABELA AS C
GROUP BY CODIGO,CLIENTE;