December 2013
Intermediate to advanced
1872 pages
153h 31m
English
A scalar function is like the standard built-in functions provided with SQL Server. It returns a single scalar value that can be used anywhere a constant expression can be used in a query. (You saw an example of this in the earlier description of the getonlydate() function.)
A scalar function typically takes one or more arguments and returns a value of a specified data type. Every T-SQL function must return a result using the RETURN statement. The value to be returned can be contained in a local variable defined within the function, or the value can be computed in the RETURN statement. The following two functions are variations of a function that returns the average salary calculated for a specified job title from the Employee ...