Stored procedures

One of the most important Transact-SQL extensions is the ability to create stored procedures. A stored procedure is a collection of SQL statements and optional control-of-flow statements stored under a name. The creator of a stored procedure can also define parameters to be supplied when the stored procedure is executed.

The ability to write your own stored procedures greatly enhances the power, efficiency, and flexibility of the SQL database language. Since the execution plan is saved after stored procedures are run, stored procedures can subsequently run much faster than standalone statements.

Stored procedures supplied by Adaptive Server, called system procedures, aid in Adaptive Server system administration. Chapter 17, “Using Stored Procedures,” discusses system procedures and explains how to create stored procedures. System procedures are discussed in detail in the Reference Manual: Procedures.

You can execute stored procedures on remote servers. All Transact-SQL extensions support return values from stored procedures, user-defined return statuses from stored procedures, and the ability to pass parameters from a procedure to its caller.