CREATE PROCEDURE

A stored procedure is a collection of statements that can be called from other queries or other stored procedures.

Grammar Syntax for SQL procedures

CREATE [OR REPLACE] PROCEDURE [IF NOT EXISTS]
[[project_name.]dataset_name.]procedure_name (procedure_argument[, ...] )
[OPTIONS(procedure_option_list)]
BEGIN
multi_statement_query
END;

procedure_argument: [procedure_argument_mode] argument_name argument_type

procedure_argument_mode: IN | OUT | INOUT

Click herearrow-up-right to go to the BigQuery specification for this syntax.

Sample Source Patterns

Basic case

CREATE OR REPLACE PROCEDURE test.proc1()
BEGIN
  RETURN;
END;

IN Parameter Mode

circle-info

IN mode parameter is removed, not required in Snowflake.

OUT Parameter Mode

circle-info

Snowflake does not allow OUTPUT parameters in procedures, one way to simulate this behavior is return its value at the end of the procedure.

INOUT Parameter Mode

circle-info

Same behavior as output parameters

Options Clause

BigQuery
Snowflake

strict_mode

Not supported in Snowflake, but by default the strict_mode is false.

circle-exclamation

Last updated

Was this helpful?