What I've found a bit weird is, if you run SELECT @@ROWCOUNT by itself in a completely fresh window then you get 1 returned... slightly odd behaviour?
I think that there was a QotD about this in the past and it generated a lot of posts due to this behaviour. It is actually by design
, and it all depends on what happens when you open first window. For example, if you open SSMS, open new window then @@rowcount
, but if you after opening new window go after database list dropdown and pick your database then select @@rowcount
simply because clicking in the dropdown silently issued use [your_db_name];
prior to you running select @@rowcount
. Whatever settings are silently ran by SSMS depends on things such as your user options, database options, SSMS version etc. The bottom line is that when you open SSMS and do
see select @@rowcount
out of the bat then it simply means that the latest silently executed for you by SSMS script affected one record.