The docs for @@ROWCOUNT say:
EXECUTE statements preserve the previous @@ROWCOUNT.
I take this to mean that @@ROWCOUNT should have the same value after an EXECUTE statement that it had before.
However, considering the following:
CREATE TABLE #wat (id int);
INSERT #wat VALUES (1),(2),(3);
SELECT @@ROWCOUNT before;
EXECUTE('INSERT #wat VALUES (1),(2);');
SELECT @@ROWCOUNT after;
DROP TABLE #wat;
On SQL Server 2016 SP2 CU 8, before
and after
are different.
Do I misunderstand something here, or is this a documentation issue?
Natively compiled stored procedures
. Please refer following statement just before theEXAMPLE
in the same@@ROWCOUNT
documentationNatively compiled stored procedures preserve the previous @@ROWCOUNT. Transact-SQL statements inside natively compiled stored procedures do not set @@ROWCOUNT.