What is the scope of @@rowcount ?MSDN doesn’t mention its scope.
Returns the number of rows affected by the last statement.
Ok.
In my SP — I’m inserting into a table , which has a insert trigger which does another insertion when a new value is inserted to the table.
Question:
To which scope the @@rowcount will refer ? (trigger or SP) ?
Granted, the article is for SQL Server 2000, but one would hope the scope doesn’t change between versions. According to the article How triggers affect ROWCOUNT and IDENTITY in SQL Server 2000,
@@ROWCOUNTwill not be affected by triggers.Specifically:
So if you update three rows, and the trigger updates five rows elsewhere, you’ll get a
@@ROWCOUNTof 3.Also, from GBN’s answer in SQL Server – is using @@ROWCOUNT safe in multithreaded applications?: