
Explanation/Reference:
Explanation:
Box 1: FUNCTION
To be able to return a value we should use a scalar function.
CREATE FUNCTION creates a user-defined function in SQL Server and Azure SQL Database. The return value can either be a scalar (single) value or a table.
Box 2: RETURNS decimal(18,2)
Use the same data format as used in the UnitPrice column.
Box 3: BEGIN
Transact-SQL Scalar Function Syntax include the BEGIN ..END construct.
CREATE [ OR ALTER ] FUNCTION [ schema_name. ] function_name
( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type
[= default ] [ READONLY ] }
[,...n ]
]
)
RETURNSreturn_data_type
[WITH <function_option> [ ,...n ] ]
[AS ]
BEGIN
function_body
RETURN scalar_expression
END
[; ]
Box 4: @OrderPrice * @CalculatedTaxRate
Calculate the price including tax.
Box 5: END
Transact-SQL Scalar Function Syntax include theBEGIN ..END construct.
References: https://msdn.microsoft.com/en-us/library/ms186755.aspx