Functions in Sql Server

Scalar Function in Sql Server

The functions which return only a single Parameter are known as Scalar function. Scalar function may or not may have Parameters that is optional but return type is Mandatory

Syntax of Scalar functions

Create Function functionName(@Parameter DataType)
Return <DataType>
AS
BEGIN
Declare @Result as <DataType>
Declare @QueryOutput <DataType>
Set @QueryOutput='Select top 1 RecordColumn from User'
@Result=@QueryOutput
RETURN @Result
END