In SQL Server user can define function to return a table or some value. Following are two ways of creating function:
1- Returning Table
-----------------Returing table
create function printTwo
(@projectId varchar, @resourceId varchar)
returns table as
return
(
select @projectId as [proj],@resourceId as [resc]
);
2- Returning Scalar(single) value
-----------------Returing scalar
create function printOne
(
@value int
)
returns int
WITH EXECUTE AS CALLER
as
begin
return @value
end
3- Checking the output by calling in different ways
select dbo.printOne(1) 'Result';
select *
from dbo.printTwo('1','2');
select dbo.printOne(1) 'Result', * from dbo.printTwo('a','b');