Running Stored Procedures


System_CAPS_ICON_warning.jpg Warning

SQL Server Native Client (SNAC) is not supported beyond SQL Server 2012. Avoid using SNAC in new development work, and plan to modify applications that currently use it. The Microsoft ODBC Driver for SQL Server provides native connectivity from Windows to Microsoft SQL Server and Microsoft Azure SQL Database.

A stored procedure is an executable object stored in a database. SQL Server supports:

  • Stored procedures:

    One or more SQL statements precompiled into a single executable procedure.

  • Extended stored procedures:

    C or C++ dynamic-link libraries (DLL) written to the SQL Server Open Data Services API for extended stored procedures. The Open Data Services API extends the capabilities of stored procedures to include C or C++ code.

When executing statements, calling a stored procedure on the data source (instead of directly executing or preparing a statement in the client application) can provide:

  • Higher performance

    SQL statements are parsed and compiled when procedures are created. This overhead is then saved when the procedures are executed.

  • Reduced network overhead

    Executing a procedure instead of sending complex queries across the network can reduce network traffic. If an ODBC application uses the ODBC { CALL } syntax to execute a stored procedure, the ODBC driver makes additional optimizations that eliminate the need to convert parameter data.

  • Greater consistency

    If an organization's rules are implemented in a central resource, such as a stored procedure, they can be coded, tested, and debugged once. Individual programmers can then use the tested stored procedures instead of developing their own implementations.

  • Greater accuracy

    Because stored procedures are usually developed by experienced programmers, they tend to be more efficient and have fewer errors than code developed multiple times by programmers of varying skill levels.

  • Added functionality

    Extended stored procedures can use C and C++ features not available in Transact-SQL statements.

    For an example of how to call a stored procedure, see Process Return Codes and Output Parameters (ODBC).

SQL Server Native Client (ODBC)
Running Stored Procedures How-to Topics (ODBC)

Community Additions