title: T-SQL XML to retrieve attribute value and the respective element value
body: <p>I have an XML column in a table. This column is called UserDef. The Xml looks like this: </p>
  
  <pre><code>&lt;UserDefs&gt;
      &lt;UserDef id="EmpNum"&gt;002&lt;/UserDef&gt;
      &lt;UserDef id="EmpDept"&gt;AUT&lt;/UserDef&gt;
      &lt;UserDef id="EmpName"&gt;XYZ ABC&lt;/UserDef&gt;
      &lt;UserDef id="EmpHireDate"&gt;2009-11-01T23:59:00-06:00&lt;/UserDef&gt;
  &lt;/UserDefs&gt;
  </code></pre>
  
  <p>What should the query look like to return a result like this: </p>
  
  <pre><code>Column1     Column2 
  --------------------
  EmpNum      002
  EmpDept     AUT
  EmpName     XYZ ABC
  EmpHireDate 2009-11-01 23:59:00
  </code></pre>
  
  <p>Thank you. </p>