A scalar function to create a custom, as follows:
The CREATE the FUNCTION the Employee ( @n int ) the RETURN int the AS the begin the RETURN (
data // need to return
) the END
sql statement parsing:
Employee: represents the creation of a scalar function name
n: represents self ago parameters, parameter names must be defined with @, followed by a space plus parameter types
return int: represents the type of returns an int
Written on the back are fixed format, returning the data to be written in the return brackets.
After writing can be performed in the scalar-valued function as seen in FIG's. To perform this function do the following sql
SELECT dbo.Employee(2)
To add dbo, otherwise it will fail to perform, can not find the object name, the parameter value of 2