I have an SP that inserts some records and updates others and deletes some. What I want is to return the count values of what was inserted and what was updated and what was deleted. I thought I could use @@ROWCOUNT but that is always giving me a 1.
After my INSERT I run:
PRINT @@ROWCOUNT
But my message console shows what really happened and this number:
(36 row(s) affected)
1
So I can see that 36 records were actually updated but @@ROWCOUNT returned a 1.
I am trying to do the same thing after the UPDATE and DELETE parts of the SP runs with the same result.
@@ROWCOUNTwill show the number of rows affected by the most recent statement – if you have any statements between theINSERTand thePRINTthen it will give you the wrong number.Can you show us a little more code so we can see the order of execution?