QuestionQ76
VerifiedDesign and develop database solutionsYou have an Azure SQL database that contains a table named Sales.Orders. Sales.Orders contains the following columns.

Reporting queries often repeat logic to calculate the number of days since an order was placed.
You need to create a scalar user-defined function (UDF) that returns the number of days between an input value of @OrderDate and the current date and time.
How should you complete the Transact-SQL code? Each value may be used once, more than once, or not at all.
Drag & Drop
CREATE FUNCTION dbo.ufn_DaysSinceOrder ( @OrderDate datetime2(0) ) BEGIN DECLARE @Days int; SELECT @Days = ; RETURN @Days; END; GO
Community Discussion