title: SQL View based on a xml column
body: <p>My problem is to build a SQL view based on a XML column.</p>
  <p>My current table has two columns. One for timestamp and second for data.
  The data-column is from XML datatype and the content is:</p>
  <pre><code>&lt;data&gt;
      &lt;entry header =&quot;Parameter1&quot; value=&quot;1&quot; type=&quot;System.Boolean&quot;/&gt;
      &lt;entry header =&quot;Parameter2&quot; value=&quot;0&quot; type=&quot;System.Boolean&quot;/&gt;
      &lt;entry header =&quot;Parameter3&quot; value=&quot;140&quot; type=&quot;System.int16&quot;/&gt;
      &lt;entry header =&quot;Parameter4&quot; value=&quot;80&quot; type=&quot;System.int16&quot;/&gt;
      &lt;entry header =&quot;Parameter5&quot; value=&quot;530602-455605&quot; type=&quot;System.String&quot;/&gt;
  &lt;/data&gt; 
  </code></pre>
  <p>Now I want to create following view:</p>
  <pre><code>Timestamp           | Parameter1 | Parameter 2 | Parameter 3 | Parameter 4 | Parameter 5
  --------------------+------------+-------------+-------------+-------------+---------------------
  2016-10-24 11:30:00 |     1      |      0      |     140     |     80      | 530602-455605
  </code></pre>
  <p>How can I do this?</p>
  <pre><code>SELECT TOP 1 
      Timestamp 
      Par1... 
      Par2...
      ParN... 
  FROM 
      TableName 
  ORDER BY 
      Timestamp DESC   
  </code></pre>
  <p>Thanks in advance!</p>
  <h1>Update</h1>
  <p>I got the following result (sorry for format):</p>
  <pre><code>Timestamp               Header  Value   ValueType
  
  2016-10-24 08:00:00.000 Abguss1 1   System.Boolean
  
  2016-10-24 08:00:00.000 Abguss  0   System.Boolean
  
  2016-10-24 08:00:00.000 Abgussgewicht   140 System.int16
  
  2016-10-24 08:00:00.000 Stopfen 80  System.int16
  
  2016-10-24 08:00:00.000 Werkzeug    530602-455605   System.String
  
  2016-10-24 08:00:20.000 Abguss1 1   System.Boolean
  
  2016-10-24 08:00:20.000 Abguss  0   System.Boolean
  
  2016-10-24 08:00:20.000 Abgussgewicht   138 System.int16
  
  2016-10-24 08:00:20.000 Stopfen 80  System.int16
  
  2016-10-24 08:00:20.000 Werkzeug    530602-455605   System.String
  
  2016-10-24 08:00:40.000 Abguss1 1   System.Boolean
  
  2016-10-24 08:00:40.000 Abguss  0   System.Boolean
  
  2016-10-24 08:00:40.000 Abgussgewicht   178 System.int16
  
  2016-10-24 08:00:40.000 Stopfen 80  System.int16
  
  2016-10-24 08:00:40.000 Werkzeug    530602-455605   System.String
  
  2016-10-24 08:01:20.000 Abguss1 1   System.Boolean
  
  2016-10-24 08:01:20.000 Abguss  0   System.Boolean
  
  2016-10-24 08:01:20.000 Abgussgewicht   158 System.int16
  
  2016-10-24 08:01:20.000 Stopfen 80  System.int16
  
  2016-10-24 08:01:20.000 Werkzeug    530602-455605   System.String
  
  2016-10-24 08:01:43.000 Abguss1 1   System.Boolean
  
  2016-10-24 08:01:43.000 Abguss  0   System.Boolean
  
  2016-10-24 08:01:43.000 Abgussgewicht   162 System.int16
  
  2016-10-24 08:01:43.000 Stopfen 80  System.int16
  
  2016-10-24 08:01:43.000 Werkzeug    530602-455605   System.String
  </code></pre>