title: Dynamic reading xml data in SQL Server
body: <p>I have a xml data schema like below. All I need is to read the xml data and store it in a temp table. The columns are dynamic (the columns below are samples only), but the attributes are constant. I am expecting the result below.</p>
  
  <pre><code>BandCode BandDescription BandName Code     Country Currency Pay1_11  Pay1_12  Pay1_13  Pay1_14  Pay1_15
  123440   Band-A          Band1    1234567  Germany  US      10000.00 10000.00 10000.00 10000.00 10000.00  
  123441   Band-B          Band2    1234567  Germany  US      10000.00 10000.00 10000.00 10000.00 10000.00 
  </code></pre>
  
  <p>Sample xml data</p>
  
  <pre><code>&lt;CookedData&gt;
     &lt;row RowNumber="1"&gt;
       &lt;Column DestinationColumnCode="BandCode" DataType="VARCHAR(3000)" Value="123440"/&gt;
       &lt;Column DestinationColumnCode="BandDescription" DataType="VARCHAR(3000)" Value="Band-A"/&gt;
       &lt;Column DestinationColumnCode="BandName" DataType="VARCHAR(3000)" Value="Band1"/&gt;
       &lt;Column DestinationColumnCode="Code" DataType="VARCHAR(3000)" Value="1234567"/&gt;
       &lt;Column DestinationColumnCode="Country" DataType="VARCHAR(3000)" Value="Germany"/&gt;
       &lt;Column DestinationColumnCode="Currency" DataType="MONEY" Value="US"/&gt;
       &lt;Column DestinationColumnCode="Pay1_11" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_12" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_13" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_14" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_15" DataType="MONEY" Value="10000.00"/&gt;
     &lt;/row&gt;
     &lt;row RowNumber="2"&gt;
       &lt;Column DestinationColumnCode="BandCode" DataType="VARCHAR(3000)" Value="123441"/&gt;
       &lt;Column DestinationColumnCode="BandDescription" DataType="VARCHAR(3000)" Value="Band-B"/&gt;
       &lt;Column DestinationColumnCode="BandName" DataType="VARCHAR(3000)" Value="Band2"/&gt;
       &lt;Column DestinationColumnCode="Code" DataType="VARCHAR(3000)" Value="1234567"/&gt;
       &lt;Column DestinationColumnCode="Country" DataType="VARCHAR(3000)" Value="Germany"/&gt;
       &lt;Column DestinationColumnCode="Currency" DataType="MONEY" Value="US"/&gt;
       &lt;Column DestinationColumnCode="Pay1_11" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_12" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_13" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_14" DataType="MONEY" Value="10000.00"/&gt;
       &lt;Column DestinationColumnCode="Pay1_15" DataType="MONEY" Value="10000.00"/&gt;
     &lt;/row&gt;
  &lt;/CookedData&gt;
  </code></pre>
  
  <p>I have researched on how to do this, however the sample code that I have found is for static columns only.</p>