Executing Statements Directly

ADO and SQL Server

ADO and SQL Server

Executing Statements Directly

Direct execution is the most basic way to execute a statement and is commonly used by applications that build and execute statements at run time. It is the most efficient method for using statements that will be executed a single time or for calling stored procedures. One drawback of direct execution is that a SQL statement must be parsed and compiled every time it is executed, which increases overhead if the statement is executed a number of times.

An application builds a character string containing an SQL statement and submits it for execution using the Execute method of the Command or Connection object. When the statement reaches the server, Microsoft® SQL Server™ 2000 compiles it into an execution plan and then immediately runs the execution plan.

For SQL Server 2000 applications, using the Execute method with parameter markers for commonly executed SQL Statements can approach the efficiency of prepared execution.