Stored Procedures
Stored procedures can make managing your database and displaying information about that database and its users much easier. Stored procedures are a precompiled collection of SQL statements and optional control-of-flow statements stored under a name and processed as a unit. Stored procedures are stored within a database; can be executed with one call from an application; and allow user-declared variables, conditional execution, and other powerful programming features.
Stored procedures can contain program flow, logic, and queries against the database. They can accept parameters, output parameters, return single or multiple result sets, and return values.
You can use stored procedures for any purpose for which you would use SQL statements, with these advantages:
- You can execute a series of SQL statements in a single stored procedure.
- You can reference other stored procedures from within your stored procedure, which can simplify a series of complex statements.
- The stored procedure is compiled on the server when it is created, so it executes faster than individual SQL statements.
The functionality of a stored procedure is dependent on the features offered by your database. For more details about what a stored procedure can accomplish for you, see Stored Procedures.
For details about working with stored procedures, see the following topics:
To | See |
---|---|
Create stored procedures to be executed from the database | Creating a Stored Procedure |
Set execute permissions to allow access to the stored procedures by specific users | Executing a Stored Procedure |
Use parameters in stored procedures | Specifying Parameters |
View a stored procedure | Viewing a Stored Procedure |
Delete stored procedures | Deleting a Stored Procedure |
Run stored procedures against your database | Executing a Stored Procedure |
Change the name of a stored procedure | Modifying and Renaming a Stored Procedure |