Using Autofetch with ODBC Cursors

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW)

When connected to an instance of SQL Server, the SQL Server Native Client ODBC driver supports an autofetch option when using any server cursor type. With autofetch, the SQLExecute or SQLExecDirect function that opens the cursor also has an implicit SQLFetchScroll(SQL_FIRST) function. The rows comprising the first rowset are returned to the bound application variables as part of the statement execution, saving another roundtrip across the network to the server. SQLGetData is not supported when the autofetch option is enabled; the result set columns must be bound to program variables.

Applications request autofetch by setting the driver-specific SQL_SOPT_SS_CURSOR_OPTIONS statement attribute to SQL_CO_AF.

See Also

Cursor Programming Details (ODBC)