SQL to XML with multiple values Hello I'm new to converting SQL to XML. I have been trying to get this to work for the past few days.

SELECT Item.foldername AS "foldername", 
Item.status, 
Item.vhrid, 
Item.firstname, 
Item.middleinitial, 
Item.lastname,
dbo.getEnumDescript(Type, 'Type') AS title,
Item.email, 
dbo.getEnumDescript(OfficeLocation, 'OfficeLocation') AS Office,
       (
    select  id.id 'practices/practice/ID',
           id.name'practices/practice/Name'
    from [dbo].[Groups] as aprac
    INNER JOIN [dbo].[PracticeGroups] as practices 
    on aprac.PracticeGroupID = practices.ID 
    where Item.vhrid = aprac.vhrid
    FOR XML path(''), type
)
FROM [dbo].[Att] as Item
FOR XML path, ROOT ('Item');


It returns this

&lt;Item&gt;
&lt;row&gt;
&lt;foldername&gt;foldername&lt;/foldername&gt;
&lt;status&gt;1&lt;/status&gt;
&lt;vhrid&gt;3&lt;/vhrid&gt;
&lt;firstname&gt;firstname&lt;/firstname&gt;
&lt;lastname&gt;lastname&lt;/lastname&gt;
&lt;title&gt;title&lt;/title&gt;
&lt;email&gt;test@test.com&lt;/email&gt;
&lt;Office&gt;office&lt;/Office&gt;
&lt;practices&gt;
  &lt;practice&gt;
    &lt;ID&gt;1&lt;/ID&gt;
    &lt;Name&gt;test1&lt;/Name&gt;
  &lt;/practice&gt;
&lt;/practices&gt;
&lt;practices&gt;
  &lt;practice&gt;
    &lt;ID&gt;2&lt;/ID&gt;
    &lt;Name&gt;test2&lt;/Name&gt;
  &lt;/practice&gt;
&lt;/practices&gt;
&lt;practices&gt;
  &lt;practice&gt;
    &lt;ID&gt;3&lt;/ID&gt;
    &lt;Name&gt;test3&lt;/Name&gt;
  &lt;/practice&gt;
&lt;/practices&gt;
&lt;practices&gt;
  &lt;practice&gt;
    &lt;ID&gt;4&lt;/ID&gt;
    &lt;Name&gt;test4&lt;/Name&gt;
  &lt;/practice&gt;
&lt;/practices&gt;
&lt;/row&gt;


I'm trying to get it in this format.

&lt;Item&gt;
&lt;row&gt;
&lt;foldername&gt;foldername&lt;/foldername&gt;
&lt;status&gt;1&lt;/status&gt;
&lt;vhrid&gt;3&lt;/vhrid&gt;
&lt;firstname&gt;firstname&lt;/firstname&gt;
&lt;lastname&gt;lastname&lt;/lastname&gt;
&lt;title&gt;title&lt;/title&gt;
&lt;email&gt;test@test.com&lt;/email&gt;
&lt;Office&gt;office&lt;/Office&gt;
&lt;practices&gt;
  &lt;practice&gt;
    &lt;ID&gt;1&lt;/ID&gt;
    &lt;Name&gt;test1&lt;/Name&gt;
    &lt;ID&gt;2&lt;/ID&gt;
    &lt;Name&gt;test2&lt;/Name&gt;
    &lt;ID&gt;3&lt;/ID&gt;
    &lt;Name&gt;test3&lt;/Name&gt;
    &lt;ID&gt;4&lt;/ID&gt;
    &lt;Name&gt;test4&lt;/Name&gt;
  &lt;/practice&gt;
&lt;/practices&gt;
&lt;/row&gt;


Any help would be thank full.
I took the liberty of assuming that you want the XML to look like this:

&lt;row&gt;
...
&lt;practices&gt;
  &lt;practice&gt;
    &lt;ID&gt;1&lt;/ID&gt;
    &lt;Name&gt;test1&lt;/Name&gt;
  &lt;/practice&gt;
  &lt;practice&gt;
    &lt;ID&gt;2&lt;/ID&gt;
    &lt;Name&gt;test2&lt;/Name&gt;
  &lt;/practice&gt;
  &lt;practice&gt;
    &lt;ID&gt;3&lt;/ID&gt;
    &lt;Name&gt;test3&lt;/Name&gt;
  &lt;/practice&gt;
  &lt;practice&gt;
    &lt;ID&gt;4&lt;/ID&gt;
    &lt;Name&gt;test4&lt;/Name&gt;
  &lt;/practice&gt;
&lt;/practices&gt;
&lt;/row&gt;


I think this is the solution you're looking for (see my comments for where I've changed your code).

SELECT Item.foldername AS "foldername", 
Item.status, 
Item.vhrid, 
Item.firstname, 
Item.middleinitial, 
Item.lastname,
dbo.getEnumDescript(Type, 'Type') AS title,
Item.email, 
dbo.getEnumDescript(OfficeLocation, 'OfficeLocation') AS Office,
       (
    select  id.id AS [practice/ID],   --- here..
           id.name AS [practice/Name] --- here..
    from [dbo].[Groups] as aprac
    INNER JOIN [dbo].[PracticeGroups] as practices 
    on aprac.PracticeGroupID = practices.ID 
    where Item.vhrid = aprac.vhrid
    FOR XML path('/practices'), type  --- and here.
)
FROM [dbo].[Att] as Item
FOR XML path, ROOT ('Item');


For obvious reasons, I haven't tried it myself, please let me know if it doesn't work.