title: Before trigger in sql server 2008
body: <p>I'm creating my first trigger in <strong>sql server 2008</strong>. I have two tables, <code>employee</code> and <code>employee_audit</code>.</p>
  
  <ol>
  <li><code>employee</code> table have three fields <code>empno</code> (<em>auto increment</em>), <code>first_name</code>  and <code>last_name</code> </li>
  <li><code>employee_audit</code> table have <code>empno</code> (<em>auto increment</em>) last_name.</li>
  </ol>
  
  <p>I want to create trigger on <code>employee</code> and update its last name and before update this last name I want to store <code>employee</code> table's <code>last_name</code> in <code>employees_audit</code> table's last_name</p>
  
  <pre><code>create trigger before_employee_update
  on employee
  after update
  as 
  declare @last_name varchar(20)
  select @last_name = i. last_name from inserted i;
  Begin 
  Insert into employees_audit(last_name) 
  values(@last_name);
  end;
  </code></pre>
  
  <p>what I have to write instead of "after"
  cz I first want to store the old last_name value in employees_audit table and then want to update last_name value in employee</p>
  
  <p>and before is not recognized trigger in sql server</p>