CREATE FUNCTION defines a scalar user defined function. Functions are dropped with DROP FUNCTION.
These functions can be used in SET and DECLARE expressions and can take constants and variables as
parameters within SELECT or other SQL statements. When operating within other SQL statements, they
cannot accept column values as input. They are evaluated at the start of the SQL Statement and have a
constant value for the rest of the life time of the SQL statement.
Example - Squares the parameter passed as input:
CREATE FUNCTION udf_squared (@nr int)
declare @result as long
set @result = @nr*@nr