the following query returns two fields (DATA1 AND DEPARTMENT) THAT ARE VARCHAR
SELECT DATO1 ,(SELECT DD.NombreDepartamento + ',' FROM CIALES AS CT INNER JOIN Departamento AS DD
ON CT.ID_DEPARTAMENTO = DD.IdDepartamento
ORDER BY CT.ID DESC
FOR XML PATH('') )
AS DEPARTAMENTO FROM TABLA
The problem I have is that the field DEPARTMENT .. as you will see is a subquery, and that with the "for xml path" I go through the results, I concatenate them and put a comma as a separator, but the problem is that also add the comma in the last record.
for example
returns = a, b, c, d, e,
I want = a, b, c, d, e
How do I do it?