title: Why can't I get the @@rowcount value?
body: <p>Below is a simplified version of SQL script I have. <code>print @RowNum</code> always shows 0, rather than the real record number of the first result set. What's wrong? Thank you.</p>
  
  <pre><code>declare @i int, @RowNum int
  set @i=0
  while @i&lt;2
  begin
      execute StoredProcedure @i --containing a big select
      if @i=0 set @RowNum=@@rowcount
      set @i=@i+1
  end
  print @RowNum
  </code></pre>