title: Executing if @@rowcount>0 resets @@rowcount to 0. Why?
body: <p><a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/08/09/proper-usage-of-rowcount.aspx" rel="noreferrer">Link</a></p>
  
  <blockquote>
    <p>@@Rowcount is used to inform the number of rows affected for the last
    select,insert,update or delete statements</p>
  
  <pre><code>declare @row int select 100 if @@rowcount&gt;0  set @row=@@rowcount ...
  </code></pre>
    
    <p>The above will return 0 because as soon as <code>if @@rowcount&gt;0</code> is executed
    it is reset to 0 as it doesn't return any rows. So always assign to
    variable first</p>
  </blockquote>
  
  <p>Why does statement <code>if @@rowcount&gt;0</code> reset <code>@@rowcount</code> to 0? Isn't the value of  <code>@@rowcount</code> affected only by select,insert,update and delete statements?</p>
  
  <p>thank you</p>