CREATE PROCEDURE

SQL CREATE PROCEDURE Keyword

The CREATE PROCEDURE command is used to define a stored procedure. A stored procedure is a pre-written block of SQL code that can be executed repeatedly to perform specific tasks such as querying data or modifying tables.

Tutorials dojo strip

SQL CREATE PROCEDURE Syntax

CREATE PROCEDURE procedure_name
AS
SQL statements

SQL CREATE PROCEDURE Example

This procedure is intended to return all records from the Patients table each time it is executed.

CREATE PROCEDURE SelectAllPatients
AS
SELECT * FROM Patients
GO

Execution:

This runs the stored procedure and displays the result of the query.

EXEC SelectAllPatients

Note: This example will in the TechKubo playground. SQLite does not support CREATE PROCEDURE or stored procedures. Stored procedures are supported in other systems like SQL Server MySQL and Oracle.

SQL CREATE PROCEDURE Labs

Tutorials dojo strip
Scroll to Top