title: Compare two sets of XML data using XQuery in SQL Server
body: <p>Suppose I store employee data in a <code>xml</code> column in my log table. Sometimes data is also updated in the <code>xml</code> column from a stored procedure.</p>
  
  <p>Here is the sample example</p>
  
  <pre><code>DECLARE @XML1 XML
  DECLARE @XML2 XML
  
  SET @XML1 = 
  '&lt;NewDataSet&gt; 
  &lt;Employee&gt;
  &lt;EmpID&gt;1005&lt;/EmpID&gt;
  &lt;Name&gt; keith &lt;/Name&gt;
  &lt;DOB&gt;12/02/1981&lt;/DOB&gt;
  &lt;DeptID&gt;ACC001&lt;/DeptID&gt;
  &lt;Salary&gt;10,500&lt;/Salary&gt;
  &lt;/Employee&gt;
  &lt;/NewDataSet&gt;'
  
  SET @XML2 = 
  '&lt;NewDataSet&gt; 
  &lt;Employee&gt;
  &lt;EmpID&gt;1006&lt;/EmpID&gt;
  &lt;Name&gt; keith &lt;/Name&gt;
  &lt;DOB&gt;05/02/1981&lt;/DOB&gt;
  &lt;DeptID&gt;ACC002&lt;/DeptID&gt;
  &lt;Salary&gt;10,900&lt;/Salary&gt;
  &lt;/Employee&gt;
  &lt;/NewDataSet&gt;'
  </code></pre>
  
  <p>There is some difference in two the <code>xml</code> data which I need to show like old value &amp; new value as a output of sql</p>
  
  <pre><code>Old Value             New Value
  ---------             ---------
  1005                  1006
  12/02/1981            05/02/1981
  ACC001                ACC002
  10,500                10,900
  </code></pre>
  
  <p>I just need to show the difference like above. So please guide me how to compare two xml data using XQuery and show the difference only in the above fashion in SQL Server. Please guide me with code snippet. thanks</p>