English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Usage and Examples of SQL CREATE PROCEDURE Keyword

SQL Keyword Reference

CREATE PROCEDURE (Create Stored Procedure)

The CREATE PROCEDURE command is used to create stored procedures.

Stored procedures are saved prepared SQL code that can be reused.

The following SQL creates a stored procedure named 'SelectAllCustomers', which selects all records from the 'Customers' table:

  CREATE PROCEDURE SelectAllCustomers
AS
SELECT * FROM Customers
GO;

Execute the following stored procedure as shown below:

  EXEC SelectAllCustomers;

SQL Keyword Reference