SET Rowcount - sets the number of rows for sql query.
When the specified number of rows are returned the execution of query stops.
SET Rowcount Syntax:
SET ROWCOUNT { number | @number_variable } ;
SET Rowcount Example:
USE model;
GO
SET ROWCOUNT 3;
GO
SELECT * FROM Departments WHERE id <=3;
GO
ID | Name |
---|---|
1 | Anthropology |
2 | Biology |
3 | Chemistry |
USE model;
GO
SET ROWCOUNT 2;
GO
SELECT * FROM Departments;
GO
ID | Name |
---|---|
1 | Anthropology |
2 | Biology |