Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone please suggest how to concatenate the rows of a dataset (that has only 1 column and 1000 rows) that are of datatype xml.
+ operator is not being helpful as it is incompatible with xml and varchar datatypes?
Pls suggest the query to perform this task.
Posted
Updated 20-Nov-10 7:38am
v2

Have a look at the link below that has some options for this:
http://www.projectdmx.com/tsql/rowconcatenate.aspx[^]

Good luck!
 
Share this answer
 
Comments
Aksh@169 21-Nov-10 1:46am    
Thanks For Your reply.. But again the problem is that i have to concatenate the rows which are of DATA TYPE XML....... please help me out.
E.F. Nijboer 22-Nov-10 3:44am    
If you look at the "The blackbox XML methods" on that page you'll see that you can specify a path that can select the desired element for each row. An example below (from msdn file link given) that shows how to select rows into a single xml.

SELECT (SELECT * FROM Customers FOR XML AUTO, TYPE).query(
'<doc>{
for $c in /Customers
return
<Person name="{data($c/@ContactName)}"/>
}')

http://msdn.microsoft.com/en-us/library/ms345137%28SQL.90%29.aspx
Use cast

CAST(xml_val AS NVARCHAR(MAX) + ..............
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900