Counting the number of deleted rows in a SQL Server stored procedure Counting the number of deleted rows in a SQL Server stored procedure sql-server sql-server

Counting the number of deleted rows in a SQL Server stored procedure


I use @@ROWCOUNT for this exact purpose in SQL2000 with no issues. Make sure that you're not inadvertantly resetting this count before checking it though (BOL: 'This variable is set to 0 by any statement that does not return rows, such as an IF statement').


Just do this:

SET NOCOUNT off ;SELECT @p1 = @@ROWCOUNT

where p1 is the output parameter you set in the stored procedure.Hope it helps.