A stored procedure is an executable object stored in a database. Microsoft® SQL Server™ supports:
One or more SQL statements precompiled into a single executable procedure.
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:
SQL statements are parsed and compiled when procedures are created. This overhead is then saved when the procedures are executed.
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.
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.
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.
Extended stored procedures can use C and C++ features not available in Transact-SQL statements.
To call remote procedures
To process return codes and output parameters