SELECT [dbo].Circle(5) AS Area
There is no standard way to run a function in SQL Server.
However, some common methods are to use a stored procedure or to use the Execute command.
//the syntax to create a function with input parameters:
CREATE FUNCTION function_name(input_parameter)
RETURNS return_type
AS
BEGIN
DECLARE
--Local Variables to be declared--
--SQL statements--
RETURN return_value
END
//example :
CREATE FUNCTION [dbo].Circle(@Radius int)
RETURNS real
AS
BEGIN
DECLARE
@Area real
SET @Area=3.14*@Radius*@Radius
RETURN @Area
END
// We will execute the function with the SELECT statement as:
SELECT [dbo].Circle(5) AS Area