Preparing and Executing Statements
With Microsoft® SQL Server™ tools, such as SQL Server Query Analyzer or the osql utility, one or more Transact-SQL statements are simply keyed and then executed. Everything needed by the Transact-SQL statements must be specified in the batch of statements that are executed. Everything must be part of the character text of the Transact-SQL statements.
The database APIs support many options in how a Transact-SQL statement is executed. Two of the most important options are:
- If a Transact-SQL statement is going to be executed several times, the application can prepare the statement once, then execute it as many times as needed. Preparing a statement directs the server to compile the statement into an execution plan. The subsequent executions are faster because they use the precompiled plan and the statement has to be compiled only once.
- Instead of having to include the actual data values for input parameters as part of the Transact-SQL statement, an application can associate, or bind, program variables with the parameters. This means that the parameter values do not have to be converted to character strings to be included in the text of the Transact-SQL statement, but instead can be used in their native format.
(c) 1988-98 Microsoft Corporation. All Rights Reserved.