BUG: @@ROWCOUNT May Be Misreported Inside a Trigger (188031)



The information in this article applies to:

  • Microsoft SQL Server 6.5
  • Microsoft SQL Server, Enterprise Edition 6.5

This article was previously published under Q188031
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.

Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbBug kbpending KB188031