I have an XML column in a table where each row of the table is a complete XML node. I am trying to simply trying to select a subset of these rows and generate an XML document out of it with a root node. I thought I could do the following, but it keeps added an extra wrapper around each node with the name of the XML column. Is there anything different I can do to not get this wrapper?
Sample Data Structure:
CREATE TABLE ActivityTable
(
XMLDATA AS XML
)
INSERT INTO [ActivityTable] VALUES ( '<Activity>This is activity one</Activity>' )
INSERT INTO [ActivityTable] VALUES ( '<Activity>This is activity two</Activity>' )
INSERT INTO [ActivityTable] VALUES ( '<Activity>This is activity three</Activity>' )
Query to get Data
SELECT
XMLdata FROM ActivityTable
FOR XML PATH(''), ROOT('RootNode')
What I’m getting:
<root>
<XMLdata>
<Activity>This is activity one</Activity>
</XMLdata>
<XMLdata>
<Activity>This is activity two</Activity>
</XMLdata>
<XMLdata>
<Activity>This is activity three</Activity>
</XMLdata>
</root>
What I want:
<root>
<Activity>This is activity one</Activity>
<Activity>This is activity two</Activity>
<Activity>This is activity three</Activity>
</root>
Columns with a Name Specified as a Wildcard Character