CREATE PROCEDURE
defines a stored procedure (CREATE OR ALTER supported)
What changes
- Input
- module body (its own statements and their sources)
- Output or change
- module definition
Syntax at a glance
CREATE [ OR ALTER ] { PROC | PROCEDURE } [schema_name.] procedure_name [ ; number ] [ { @parameter_name [ type_schema_name. ] data_type } [ VARYING ] [ NULL ] [ = default ] [ OUT | OUTPUT | [READONLY] ] [ ,...n ] [ WITH <procedure_option> [ ,...n ] ] [ FOR REPLICATION ] AS { [ BEGIN ] sql_statement [;] [ ...n ] [ END ] } [;]
Work example
An application needs a named routine for a stable database operation.
Review parameter types, transaction ownership, error handling, execution context, and result shape in a lab.
Check your work The procedure handles empty and invalid inputs and returns the documented result without hidden state changes.
Open Microsoft Learn for full syntax, permissions, and details for your version.