title: Converting XML data to SQL table
body: <p>I have the following XML data with me. I need to convert this to SQL table.</p>
  
  <pre><code>&lt;SalesDetails&gt;
    &lt;Customer Name="Johny" DateofBirth="1990-01-02T00:00:00"&gt;
    &lt;OrderInfo&gt;
      &lt;OrderDate&gt;1993-02-03T00:00:00&lt;/OrderDate&gt;
      &lt;OrderAmount&gt;1000&lt;/OrderAmount&gt;
    &lt;/OrderInfo&gt;
    &lt;/Customer&gt;
   &lt;/SalesDetails&gt;
  </code></pre>
  
  <p>Can anyone help me with a SQL query that gives the above XML file as output?</p>
  
  <p>In my initial attempt, I have created two tables @TI and @T2. I had then inserted different values into it. I had then queried it as :</p>
  
  <pre><code>SELECT
  (SELECT * FROM @T1 FOR XML RAW('Sales') , TYPE),
  (SELECT * FROM @T2 FOR XML PATH('OrderInfo') , TYPE) 
  FOR XML PATH('') , ROOT('SalesDetails')
  </code></pre>
  
  <p>But I need the output in the first XML format based on SQL tables and corresponding joins. That is, when the name of a customer is displayed, his corresponding order information needs to be displayed. I do not want it in a grouped format.</p>