User defined scalar function
returns single value as a result of function. We can return any data-type value
from function. When you want to return single value, you can use scalar valued
function.
Create Scalar Valued function:
Create Table:
Create Scalar Valued function:
Create function fnGetStudent_Info
(
@age int
)
returns int
As
Begin
return (Select COUNT(*) from Student_info where Age=@age);
return (Select COUNT(*) from Student_info where Age=@age);
End
How to Execute Function:
select dbo.fnGetStudent_Info(25) as 'TotalNo'
Output: