SELECT Client.Name,SUBSTRING(COALESCE((SELECT ', '+RTRIM(Invoice.ID) FROM ClientInvoice (NOLOCK) INNER JOIN Invoice ON Client.NoInvoice=Invoice.Numero WHERE ClientInvoice.NoClient=Client.Numero FOR XML PATH (''),TYPE).value('.','varchar(max)'),''),3,1000) AS InvoiceID FROM ClientI just do not understand how the other was working and I had to adjust it tonight to fix this issue.