A subroutine stored in a database and executed by the database management system. The subroutine may be written in the same language in which the database is queried and may be precompiled to improve performance.
Typically a stored procedure encapsulates some business process. Performing this on the database server avoids the network overhead of transferring input data to the client for processing. This would be particularly significant if processing lots of data and returning a small result set like a total or maximum. Stored procedures also provide consistent implementation of the business logic to clients written in different languages and running in different environments.
Some financial systems allow databases access through stored procedures alone, this restricts actions on the data to a small number of auditable queries.
Sybase SQL Server (Adaptive Server Enterprise) was the first commercially successful RDBMS to support stored procedures.