Remote Procedure Calls

The SQL Server driver uses the RPC facility in SQL Server to run procedures rather than pass procedures to SQL Server in an SQL statement. A procedure can be:

RPCs have the following advantages over procedures passed in an SQL statement:

    To run a statement as an RPC, an application
  1. Constructs an SQL statement.
  2. Calls SQLBindParameter for each parameter in the statement.
  3. Prepares the statement with SQLPrepare. (Note that the SQL_USE_PROCEDURE_FOR_PREPARE connection option must be set to SQL_UP_ON.)
  4. Executes the statement with SQLExecute.
    To run a procedure as an RPC, an application
  1. Constructs an SQL statement that uses the ODBC procedure syntax. The statement uses parameter markers for each input, input/output, and output parameter, and for the procedure return value (if any).
  2. Calls SQLBindParameter for each input, input/output, and output parameter, and for the procedure return value (if any).
  3. Executes the statement with SQLExecDirect.

Note If an application submits a procedure using the SQL Server syntax (as opposed to the ODBC procedure syntax), the SQL Server driver passes the procedure call to SQL Server as an SQL statement rather than as an RPC.