Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 2.93 KB

running-stored-procedures-call-stored-procedures.md

File metadata and controls

42 lines (31 loc) · 2.93 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Call Stored Procedures (ODBC)
Learn how to add a data source by using ODBC Administrator, programmatically, or using a file, before using ODBC applications with SQL Server 2005 or later.
markingmyname
maghan
03/06/2017
sql
native-client
reference
stored procedures [ODBC], calling

Running Stored Procedures - Call Stored Procedures

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW]

The [!INCLUDEssNoVersion] ODBC driver supports executing stored procedures as remote stored procedures. Executing a stored procedure as a remote stored procedure allows the driver and the server to optimize the performance of executing the procedure.

When a SQL statement calls a stored procedure using the ODBC CALL escape clause, the [!INCLUDE ssnoversion-md] driver sends the procedure to SQL Server using the remote stored procedure call (RPC) mechanism. RPC requests bypass much of the statement parsing and parameter processing in SQL Server and are faster than using the Transact-SQL EXECUTE statement.

For a sample application that demonstrates this feature, see Process Return Codes and Output Parameters (ODBC).

To run a procedure as an RPC

  1. Construct a SQL statement that uses the ODBC CALL escape sequence. The statement uses parameter markers for each input, input/output, and output parameter, and for the procedure return value (if any):

    {? = CALL procname (?,?)}  
    
  2. Call SQLBindParameter for each input, input/output, and output parameter, and for the procedure return value (if any).

  3. Execute the statement with SQLExecDirect.

Note

If an application submits a procedure using the Transact-SQL EXECUTE syntax (as opposed to the ODBC CALL escape sequence), the SQL Server ODBC driver passes the procedure call to SQL Server as a SQL statement rather than as an RPC. Also, output parameters are not returned if the Transact-SQL EXECUTE statement is used.

See Also

Batching Stored Procedure Calls
Running Stored Procedures
Calling a Stored Procedure
Procedures