A stored procedure is a callable code module that can be installed on a database manager. Normally they are written in the native query language or a specialist language such as PL/SQL. Some database management systems allow other languages to be used.
Stored procedures export an API that can be used from other SQL code. They can be used to encapsulate complex operations, provide a secure API around sensitive data or as a platform to develop a process that needs to execute on the server for performance reasons.