tags:

views:

22

answers:

1

I have an online form, whereby each entry adds the data as xml to an xml column in SQL.

ApplicationID(uniqueidentifier) | DateModified | ApplicationForm(XML)

What I need to do is perform a select query that will grab all the ApplicationForm xml values, and concatenate them together to form one result, e.g.

Row1: <ApplicationForm type=""></ApplicationForm>
Row2: <ApplicationForm type=""></ApplicationForm>

Select result:

<Applications>
   <ApplicationForm type=""></ApplicationForm>
   <ApplicationForm type=""></ApplicationForm>
</Applications>
A: 

Take a look at this page, which lists quite a number of ways to concatenate rows of data.

lc
There's probably a neater way than string concatenation though seeing as the input rows and desired output are both XML.
Martin Smith
Have looked at XML AUTO etc, but the best I can get is <Root><ApplicationForm><ApplicationForm></ApplicationForm></ApplicationForm>. The xml data has the "root" node already, which the column is adding in as well
mickyjtwin
@mickyjtwin: In your `FOR XML AUTO`, you could probably add a `, ROOT('Applications')` and thus define what that root node should be called
marc_s
@marc_s, yes I have tried that, which is great, but it is the replication of the ApplicationForm elements, as it is written in the original xml value, and it is also the column name. I only need it once.
mickyjtwin