Msg 507, Level 16, State 2, Line 3
Invalid argument for SET ROWCOUNT. Must be a non-null non-negative integer.
This error message appears, when you try to call SET ROWCOUNT with an invalid argument.
The T-SQL statement can be parsed, but causes the error at runtime.
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The invalid argument must be corrected.
All versions of SQL Server.
DECLARE @i INT
SET @i = -1
SET ROWCOUNT @i
Interestingly this error is not raised, when you directly use SET ROWCOUNT with a negative number. SET ROWCOUNT -1 raises the error 102.