Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 2.28 KB

setmaxrows-method-sqlserverstatement.md

File metadata and controls

46 lines (33 loc) · 2.28 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic apilocation apiname apitype
setMaxRows Method (SQLServerStatement)
setMaxRows Method (SQLServerStatement)
David-Engel
davidengel
01/19/2017
sql
connectivity
reference
sqljdbc.jar
SQLServerStatement.setMaxRows
Assembly

setMaxRows Method (SQLServerStatement)

[!INCLUDEDriver_JDBC_Download]

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

SQLServerException

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 [!INCLUDEjdbcNoVersion] 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 [!INCLUDEtsql] 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 [!INCLUDEssNoVersion] Books Online.

See Also

SQLServerStatement Members
SQLServerStatement Class