title: SQL Server trigger : update query new vs old data
body: <p>I have two tables. One has employee info in it. The other I want to add records to based on this employee table.</p>
  
  <p>What I want to happen is whenever there are salary adjustments made to the employee table (by an UDPATE query), the extra table will have a row added to it containing a new event ID and the amount by which salaries have been adjusted (so if 5 people's salaries are increased by £1000, then the row will have the adjustment at £5000).</p>
  
  <p>I've created the trigger and it adds the row with each update. However what it doesn't do is only bring in the additional salary. I can't think how to do that. I have this code so far;</p>
  
  <pre><code>Create trigger Salaryupdate
  On TBL_Employees 
  For update
  As
      Insert TBL_audit (notes,Delta,AdjDate)
          Select 'Salary update', sum(salary), getdate()
          From TBL_Employees 
  </code></pre>
  
  <p>I know the <code>sum</code> bit is wrong as I only want the change in salary value, not the total sum.</p>
  
  <p>How can I find the difference between new and old values for the changed rows (or other method)?</p>
  
  <p>I'm using SQL Server 2008.</p>