title: Why is @@rowcount equal to 1 when run in complete isolation?
body: <p>According to the Microsoft <a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/rowcount-transact-sql?redirectedfrom=MSDN&amp;view=sql-server-ver15" rel="nofollow noreferrer"><code>@@ROWCOUNT</code></a> documentation,</p>
  <blockquote>
  <p>Statements that make a simple assignment always set the @@ROWCOUNT
  value to 1. No rows are sent to the client. Examples of these
  statements are: SET @local_variable, RETURN, READTEXT, and select
  without query statements such as SELECT GETDATE() or SELECT 'Generic
  Text'.</p>
  </blockquote>
  <p>Somebody else on Stackoverflow also asked <a href="https://stackoverflow.com/questions/23102805/rowcount-returning-1-when-no-update-made">why @@rowcount equals 1 when no rows are updated</a>.  However, that question used an update statement.</p>
  <p>My confusion starts with this example, where no other statements appear:</p>
  <p><a href="https://i.stack.imgur.com/sqZMf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sqZMf.png" alt="enter image description here" /></a></p>
  <p>Reading further into this (<em><a href="https://stackoverflow.com/questions/7705509/executing-if-rowcount0-resets-rowcount-to-0-why">Executing if @@rowcount&gt;0 resets @@rowcount to 0. Why?</a></em>), I then did a second test:</p>
  <p><a href="https://i.stack.imgur.com/7hryH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7hryH.png" alt="enter image description here" /></a></p>
  <p><strong>I'm curious to understand please why @@rowcount equals 1 when no other statements are used?</strong>  Is it because the actual <code>SELECT @@ROWCOUNT</code> statement itself causes an update of @@rowcount?</p>