Knowledge Base

BUG: @@ROWCOUNT May Be Misreported Inside a Trigger

Article ID: 188031

Article Last Modified on 10/16/2003


APPLIES TO


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.

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

Keywords: kbbug kbpending KB188031