How to create a simple table valued function?
In simple/Inline table-valued functions: it returns the data as a table, and can use only one single statement. It can accept multiple parameters as inputs, it can return only one single table.
Syntax:
Create function functionname( @input_paramters datatype)
Return table
As
Return (statement to select the table)
Sample function:
CREATE FUNCTION dbo.udf_get_employs (
@p_Salarycat DEC(10,2)
)
RETURNS table
AS
RETURN (select * from employee where EMPLOYSALARY>@p_Salarycat)
For the select:
select * from udf_get_employs(2150)
select * from udf_get_employs(2250)