QuestionQ36

Design and develop database solutions

You have an Azure SQL Database.

You need to create a scalar user-defined function (UDF) that returns, as one positive integer, the number of whole years between an input parameter named @OrderDate and the current date/time. The function must be created in Azure SQL Database.

You write the following code.

Question Image

What should be inserted at line 05?

Explanation

A Transact-SQL scalar UDF body returns its result through RETURN scalar_expression. DATEDIFF(year, @OrderDate, GETDATE()) uses the required DATEDIFF(datepart, startdate, enddate) argument order, returns an int, and measures the year difference from the order date to the current date/time. DATEDIFF (Transact-SQL) CREATE FUNCTION (Transact-SQL)

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!