title: SQL Server 2005 For XML Explicit - Need help formatting
body: <p>I have a table with a structure like the following:</p>
  <hr />
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>LocationID</th>
  <th>AccountNumber</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>long-guid-here</td>
  <td>12345</td>
  </tr>
  <tr>
  <td>long-guid-here</td>
  <td>54321</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>To pass into another stored procedure, I need the XML to look like this:</p>
  <pre><code>&lt;root&gt; 
      &lt;clientID&gt;12345&lt;/clientID&gt;
      &lt;clientID&gt;54321&lt;/clientID&gt;
  &lt;/root&gt;
  </code></pre>
  <p>The best I've been able to do so far was getting it like this:</p>
  <pre><code>&lt;root clientID=&quot;10705&quot;/&gt;
  </code></pre>
  <p>I'm using this SQL statement:</p>
  <pre><code>SELECT
      1 as tag,
      null as parent,
      AccountNumber as 'root!1!clientID'
  FROM
      Location.LocationMDAccount
  WHERE
      locationid = 'long-guid-here'
  FOR XML EXPLICIT
  </code></pre>
  <p>So far, I've looked at the documentation on <a href="http://msdn.microsoft.com/en-us/library/ms345137.aspx" rel="nofollow noreferrer">the MSDN page</a>, but I've not come out with the desired results.</p>
  <hr />
  <p>@KG,</p>
  <p>Yours gave me this output actually:</p>
  <pre><code>&lt;root&gt;
    &lt;Location.LocationMDAccount&gt;
      &lt;clientId&gt;10705&lt;/clientId&gt;
    &lt;/Location.LocationMDAccount&gt;
  &lt;/root&gt;
  </code></pre>
  <p>I'm going to stick with the <code>FOR XML EXPLICIT</code> from Chris Leon for now.</p>