Stored Procedures & UDFs (JavaScript, SQL, Python)
Encapsulate reusable logic and procedural workflows directly inside Snowflake.
Snowflake supports both stored procedures and user-defined functions (UDFs), but they serve different purposes. Stored procedures encapsulate procedural logic — control flow, loops, multiple DML statements, error handling — and are invoked with CALL. UDFs, by contrast, are scalar or tabular functions invoked inline within a SQL query (like SELECT my_func(col) FROM table), and must return a value without side effects beyond that computation (for scalar/table UDFs).
A UDF is like a calculator function you plug into a spreadsheet formula — cell in, value out; a stored procedure is more like a macro that can open dialogs, make decisions, and touch several sheets in sequence.