ROWCOUNT
ROWCOUNT in SQL is a function that is used to limit the number of rows affected by a query. It is specifically useful in procedures and triggers. The function is set with an integer number until the specified number of rows is affected. It always counts the number of rows affected and if the number of affected rows reaches the number set in ROWCOUNT, the query execution stops.
Example
Output
Explanation
In the SQL code example, the SET ROWCOUNT 5;
statement is limiting the number of rows returned by the SELECT * FROM Products;
statement to 5 rows. This allows users to limit the results of their queries to a manageable number.