nerdexam
Snowflake

DAA-C01 · Question #48

In what ways do stored procedures differ from user-defined functions (UDFs) in SQL?

The correct answer is D. Stored procedures can't execute repetitive tasks like UDFs.. There appears to be an error in this answer key - D is actually incorrect, and the correct answer is C. Why C is correct: UDFs (User-Defined Functions) allow developers to encapsulate custom logic - string manipulation, calculations, business rules - and call that logic directly

Data Modeling and Transformation

Question

In what ways do stored procedures differ from user-defined functions (UDFs) in SQL?

Options

  • AStored procedures and UDFs are interchangeable in SQL.
  • BStored procedures only handle basic arithmetic operations.
  • CUDFs allow custom-defined operations on data, extending SQL functionalities.
  • DStored procedures can't execute repetitive tasks like UDFs.

How the community answered

(44 responses)
  • B
    2% (1)
  • C
    2% (1)
  • D
    95% (42)

Explanation

There appears to be an error in this answer key - D is actually incorrect, and the correct answer is C.

Why C is correct: UDFs (User-Defined Functions) allow developers to encapsulate custom logic - string manipulation, calculations, business rules - and call that logic directly inside SQL queries (e.g., SELECT my_func(column) FROM table). This genuinely extends SQL's built-in functionality in a way stored procedures cannot, since stored procedures are called with EXEC/CALL and cannot be embedded inline in a query.

Why D is wrong (and shouldn't be marked correct): Stored procedures absolutely can execute repetitive tasks - in fact, they're commonly used for batch operations, loops, and scheduled jobs. Claiming they "can't" do this is factually false.

Why A is wrong: Stored procedures and UDFs are not interchangeable. UDFs return a value usable inside queries; stored procedures execute a block of logic and may return result sets or output parameters but can't be used inline in a SELECT.

Why B is wrong: Stored procedures are far more powerful than "basic arithmetic" - they support conditional logic, transactions, error handling, DDL statements, and more.

Memory tip: Think of a UDF like a custom Excel formula - it plugs into an expression and returns a value. A stored procedure is more like a script you run separately. "Functions go inside queries; procedures are called on their own."

Flag this to your instructor: the answer key lists D, but C is the defensible correct answer based on standard SQL definitions.

Topics

#Stored Procedures#UDFs#SQL Scripting#Data Transformation

Community Discussion

No community discussion yet for this question.

Full DAA-C01 Practice