Export (0) Print
Expand All

Batches of Statements

SQL Server 2000

Batches of Statements

  New Information - SQL Server 2000 SP3.

A batch of Microsoft® SQL Server™ statements contains two or more SQL statements, separated by a semicolon (;), built into a single string passed to SQLExecDirect or SQLPrepare. For example:

      "SELECT * FROM authors; SELECT * FROM titles",

Batches can be more efficient than submitting statements separately because network traffic is often reduced. Use SQLMoreResults to get positioned on the next result set when finished with the current result set.

Batches can always be used when the ODBC cursor attributes are set to the defaults of a forward-only, read-only cursor with a rowset size of 1.

If a batch is executed when using server cursors against SQL Server, the server cursor is implicitly converted to a default result set. SQLExecDirect or SQLExecute return SQL_SUCCESS_WITH_INFO, and a call to SQLGetDiagRec returns:

szSqlState = "01S02", pfNativeError = 0
szErrorMsg = "[Microsoft][ODBC SQL Server Driver]Cursor type changed."

Batches are not supported with server cursors against SQL Server version 6.5 or earlier. SQLExecDirect or SQLExecute return SQL_ERROR, and a call to SQLGetDiagRec returns one of three errors. For more information, see Constructing SQL Statements for Cursors.

Security Note  Batch files may contain credentials stored in plain text. Credentials may be echoed to the user's screen during batch execution.

See Also



© 2015 Microsoft