Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

CREATE PROCEDURE

CREATE PROCEDURE

The CREATE PROCEDURE command establishes a stored procedure, which is a precompiled set of SQL instructions that can be saved and reused.

The provided SQL creates a stored procedure named “SelectAllCustomers,” which retrieves all records from the “Customers” table.

Example

CREATE PROCEDURE SelectAllCustomers
AS
SELECT * FROM Customers
GO;

Execute the aforementioned stored procedure in the following manner:

Example

EXEC SelectAllCustomers;