title: SQL Server compare values of two rows of same table and get not matching column names
body: <p>I need to compare two rows (<code>INSERTED</code> &amp; <code>DELETED</code>) of the same table and compare values. And then I need to get the not matching columns. Inside a trigger.</p>
  
  <p>Here what I've tried so far but I 've no idea of how to compare these two rows and get column names which contains different values .</p>
  
  <pre><code>SELECT * 
  FROM inserted i
  INNER JOIN deleted d ON d.PurchasingDocItemNo = i.PurchasingDocItemNo 
                       AND d.PurchasingDocNo = i.PurchasingDocNo
                       AND d.ReferenceDocumentNo = i.ReferenceDocumentNo
                       AND d.ProductNo = i.ProductNo
  </code></pre>