Executing Statements (ODBC)
The SQL Native Client ODBC driver offers a variety ways to execute SQL statements in a SQL Server database:
- Direct execution
- Prepared execution
Direct execution involves building a character string containing a Transact-SQL statement and submitting it for execution using the SQLExecDirect function. Prepared execution involves building a character string containing a Transact-SQL statement and then executing it in two stages. The first stage uses the SQLPrepare function to parse and compile the execution plan for the statement in the Motore di database. The second stage uses the SQLExecute function to execute the previously prepared execution plan. This saves the parsing and compiling overhead on each execution. Prepared execution is commonly used by applications to repeatedly execute the same, parameterized SQL statement.
Both direct and prepared execution can execute a single Transact-SQL statement or a batch of SQL statements, or they can call a stored procedure.