First we need to create the function...
CREATE FUNCTION dbo.AddTwoNumbers(@Value1 as int, @Value2 as int)
RETURNS int
BEGIN
DECLARE @Result int
SET @Result = @Value1 + @Value2
RETURN @Result
END
GO
Here is how we actually use the function...
SELECT dbo.AddTwoNumbers(5, 8) AS Result
GO
The SELECT statement outputs the integer 13.