Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql function

//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
 
PREVIOUS NEXT
Tagged: #sql #function
ADD COMMENT
Topic
Name
9+3 =