SnowPro Core Certification — Question 528
What is the difference between a stored procedure and a User-Defined Function (UDF)?
Answer options
- A. Stored procedures can execute database operations while UDFs cannot.
- B. Returning a value is required in a stored procedure while returning values in a UDF is optional.
- C. Values returned by a stored procedure can be used directly in a SQL statement while the values returned by a UDF cannot.
- D. Multiple stored procedures can be called as part of a single executable statement while a single SQL statement can only call one UDF at a time.
Correct answer: A
Explanation
The correct answer is A because stored procedures are designed to perform tasks that can include executing database operations, while UDFs are intended to return values without performing such operations. Options B and C are incorrect because stored procedures do not require a return value, and UDFs can indeed return values that can be used in SQL statements. Option D is also incorrect as multiple UDFs can be utilized within a single statement, but each can only execute one at a time.