IT:AD:SQL Server:HowTo:SQL:How to use @@ROWCOUNT
Summary
Returns the number of rows affected by the last statement.
Notes
Useful in stored procs to branch.
USE AdventureWorks2012; GO UPDATE HumanResources.Employee SET JobTitle = N'Executive' WHERE NationalIDNumber = 123456789 IF @@ROWCOUNT = 0 PRINT 'Warning: No rows were updated'; GO