Understanding Stored Procedures

Stored procedures are SQL statements that are stored on the DBMS server itself. Instead of entering SQL directly, you can call the stored procedure by name to execute the stored SQL. Stored procedures are invaluable for several reasons:

  • Stored procedures execute more quickly than straight SQL statements because the code saved on the server is already parsed and ready for use.

  • Stored procedures can contain multiple SQL operations. This enables you to call a single command and execute a set of statements (without having to specify them individually).

  • Depending on the DBMS being used, stored procedures can return multiple result sets, as well as output parameters.

  • Stored procedures can be used to hide complex data structures. ...

Get Sams Teach Yourself SQL in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.