I'm doing a select on a table only selecting two columns.
I would like to construct the following XML
<root>
<choice value='1'>choice 1</choice>
<choice value='2'>choice 2</choice>
<choice value='3'>choice 3</choice>
</root>
I can currently get:
<root>
<choice value="1">choice 1</choice>
</root>
<root>
<choice value="2">choice 2</choice>
</root>
<root>
<choice value="3">choice 3</choice>
</root>
using this SQL:
SELECT
ID AS 'choice/@value',
DisplayName AS 'choice'
FROM tablename
WHERE [Status] = 'open'
FOR XML PATH ('root')
What do I need to change to get that format? i.e. the choice elements within one root element?
Thanks,