title: Should @@rowcount persist from a trigger into the proc its calling?
body: <p>In other words, if I have a trigger that calls a proc; should I be able to check <code>@@rowcount</code> in the first line of the proc?  And should <code>@@rowcount</code> have a value based on the last SQL statment executed in the trigger?</p>
  
  <p>I'm debugging a proc which I did not write.  First line of the proc is</p>
  
  <pre><code>if @@rowcount=0
  RETURN
  </code></pre>
  
  <p>The proc is called by a trigger.  The last thing the trigger does before it calls the proc is to:</p>
  
  <pre><code>INSERT INTO #temp_table (some fields...)
  SELECT some fields.. FROM inserted
  
  EXEC SOMEPROC
  </code></pre>
  
  <p>What's happening is that <code>@@rowcount</code> in the proc is always 0 and the proc ends before it does anything.  The fix is pretty easy in that I'd just move the <code>@@rowcount</code> check into the trigger and take it out of the proc.</p>
  
  <p>But its curious to me why it was written this way in the first place.  Almost like it used to work at some point and now it doesn't?  I just wanted to check and see if maybe there was some change in behavior between SQL2005 and SQL2008 or some system setting that got flipped.  Or did one of my predecessors just write bad code that never worked?</p>