title: sybase update trigger - check multiple rows for update
body: <p>I am writing a trigger in a Sybase ASE database which fires on a update and compares the value before and after the update. I do this to verify if the update has actually changed the data. If this is the case it adds a row to a monitoring table. Unfortunately the trigger only works if the update command only affects 1 row. If it is affecting more than one row i get this error:</p>
  
  <pre><code>Msg 512, Level 16, State 5:
  Server 'myserver', Procedure 'myproc', Line 2:
  Subquery returned more than 1 value.  This is illegal when the subquery follows =, !=, &lt;, &lt;= , &gt;, &gt;=, or when the subquery is used as an expression.
  </code></pre>
  
  <p>my proc looks like this:</p>
  
  <pre><code>create trigger mytrigger on mytable for update as
  
  set nocount on
  
  /* now do the insert if colum was updated  */
  if update(col_a) and (select col_a from inserted) not in (select col_a from deleted) 
  begin
      insert into monitoring_table (login,tablename,field,action,pstamp) 
          select suser_name(),'mytable','col_a','U',getdate() from inserted
  end
  /* now do the insert if colum was updated  */
  if update(col_b) and (select col_b from inserted) not in (select col_b from deleted) 
  begin
      insert into monitoring_table (login,tablename,field,action,pstamp) 
          select suser_name(),'mytable','col_b','U',getdate() from inserted
  end
  go
  </code></pre>
  
  <p>any idea how i can get around this multi update problem within my trigger?</p>