setMaxRows Method (SQLServerStatement)
Sets the limit for the maximum number of rows that any SQLServerResultSet object can contain to the given number.
Syntax
public final void setMaxRows(int max)
Parameters
max
An int that indicates the maximum number of rows, or 0 if there is no limit.
Exceptions
Remarks
This setMaxRows method is specified by the setMaxRows method in the java.sql.Statement interface.
This setMaxRows method has no effect for dynamic scrollable cursors. The application should use SELECT TOP N SQL syntax to limit the number of rows returned from potentially large result sets.
When the setMaxRows method is called, the Microsoft JDBC Driver for SQL Server executes the SET ROWCOUNT SQL statement when it runs the application's query. This causes the JDBC driver to limit the maximum number of rows affected by all the Transact-SQL statements executed by that query, not just the number of rows returned by that query. If the application needs to set a limit only on the top-level SQLServerResultSet object, it should use SELECT TOP N SQL syntax in the query instead of the setMaxRows method.
For more information about the SET ROWCOUNT SQL statement, see the "SET ROWCOUNT (Transact-SQL)" topic in SQL Server Books Online.
See Also
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho