BUG: @@ROWCOUNT May Be Misreported Inside a Trigger

ID: Q188031


The information in this article applies to:

BUG #: 16630 (SQLBUG_65)

SYMPTOMS

When joining two tables for a condition during an update of a table inside a trigger, the @@ROWCOUNT global variable may return the number of joins, rather than the number of affected rows.

This behavior only occurs if the @@ROWCOUNT global variable is checked within the Transact-SQL code of a trigger. If it is checked outside of a trigger, @@ROWCOUNT behaves as expected.


WORKAROUND

To work around this problem, check count(*) on the inserted table, rather than @@ROWCOUNT within the trigger Transact-SQL code.


STATUS

Microsoft has confirmed this to be a problem in SQL Server and SQL Server Enterprise Edition version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Additional query words: EE SQLEE TSQL T-SQL tran-sql trans-sql tran trans


Keywords          : SSrvTran_SQL kbbug6.50 
Version           : WINNT:6.5
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: April 19, 1999