Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML path returns duplicate entries
Message
From
09/04/2013 23:08:13
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
XML path returns duplicate entries
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01570554
Message ID:
01570554
Views:
44
A while ago, someone gave me a XML path syntax to include in a SQL command to return child entries. It looked something like this:
SELECT Client.Name,SUBSTRING(COALESCE((SELECT ', '+RTRIM(Invoice.ID)
 FROM ClientInvoice (NOLOCK)
 WHERE ClientInvoice.NoClient=Client.Numero FOR XML PATH (''),TYPE).value('.','varchar(max)'),''),3,1000) AS InvoiceID
 FROM Client
 INNER JOIN Invoice ON Client.NoInvoice=Invoice.Numero
So, basically, the goal was to obtain in the SQL result a column named InvoiceID with all the Invoice.ID values separated by a comma and a space. So, I could have "1234, 1500, 1600, 1800" in the SQL result InvoiceID field.

This used to work. Now, it returns the same values such as "1234, 1234, 1234, 1234". I wonder if this is a configuration that got changed on SQL Server, a new version, etc.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform