Exam DP-800 Topic 2 Question 3 Discussion

Actual exam question for Microsoft's DP-800 exam
Question #: 3
Topic #: 2
You have an Azure SQL database.
You need to create a scalar user-defined function (UDF) that returns the number of whole years between an input parameter named @OrderDate and the current date/time as a single positive integer. The function must be created in Azure SQL Database.
You write the following code.

What should you insert at line 05?

Suggested Answer: D Vote an answer

Use RETURN to produce the scalar value of the function.
In an Azure SQL Database scalar function (a user-defined function that returns a single value), you must use the RETURN statement to return the scalar value.
The RETURN statement immediately terminates the function's execution and returns the value specified in its argument to the calling statement or procedure. The value returned must be of the data type specified in the RETURNS clause of the function definition.
The second argument to DATEDIFF should be @OrderDate as it is the start date, while the third argument is the end date, which is the current date.
Note:
DATEDIFF (Transact-SQL)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed between the specified startdate and enddate.
Syntax
DATEDIFF ( datepart , startdate , enddate )
Arguments
datepart
Specifies the units in which DATEDIFF reports the difference between the startdate and enddate.
Commonly used datepart units include month or second.
Reference:
https://learn.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql

by Merlin at Jun 24, 2026, 09:11 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10