SET NOCOUNT ON clearing @@ROWCOUNT in trigger
Posted on 2004-08-24
On Books online it says:
"The @@ROWCOUNT function is updated even when SET NOCOUNT is ON"
Thus, I created the following trigger:
CREATE TRIGGER triggerMaster ON dbo.CG_BalanceMovements
set nocount on
if (@@rowcount = 1)
-- do interesting stuff --
raiserror ('Tried to add %d records, but only one BalanceMovement can be registered at a time .' , 16, 1, @@rowcount)
Then if I insert 1 row on enterprise manager, I get an error saying that I'm trying to insert 0 rows ... but if I comment out, the set nocount on, it works perfectly!
Why is this?