Bird
0
0

What is wrong with this function definition?

medium📝 Debug Q7 of 15
SQL - Stored Procedures and Functions
What is wrong with this function definition?
CREATE FUNCTION dbo.GetDate() RETURNS DATETIME AS BEGIN SELECT GETDATE() END
AFunction must use RETURN, not SELECT
BGETDATE() is not a valid function
CMissing parameter declaration
DRETURNS clause should be INT
Step-by-Step Solution
Solution:
  1. Step 1: Understand return statement in scalar functions

    Scalar functions must use RETURN to send back a value, not SELECT.
  2. Step 2: Identify error in function body

    The function uses SELECT GETDATE() without RETURN, which is invalid.
  3. Final Answer:

    Function must use RETURN, not SELECT -> Option A
  4. Quick Check:

    Scalar functions require RETURN statement [OK]
Quick Trick: Use RETURN, not SELECT, in scalar functions [OK]
Common Mistakes:
  • Using SELECT instead of RETURN
  • Assuming GETDATE() is invalid
  • Thinking parameters are mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes