Types of Function
1.
System Defined Function
These functions are defined by
Sql Server for different purpose. We have two types of system defined function
in Sql Server
Scalar Function
Scalar functions operates on a
single value and returns a single value. Below is the list of some useful Sql
Server Scalar functions.
System Scalar Function
- abs(-9.37) : returns absolute number of the given number means 9.37.
- rand(15): will generate random number of 15 characters.
- round(1.567): will round off the given number to 2 places of decimal means 1.57
- upper('sqlserver'): will returns upper case of given string means ‘SQLSERVER’
- lower(SQLSERVER’): will returns lower case of given string means 'sqlserver'
- ltrim(' sqlserver'): will remove the spaces from left hand side of 'sqlserver' string.
- convert(int, 72.66): will convert the given float value to integer means 72.
Aggregate Function
Aggregate
functions operates on a collection of values and returns a single value. Below
is the list of some useful Sql Server Aggregate functions.
System
Aggregate Function
- max(): returns maximum value from a collection of values.
- min(): returns minimum value from a collection of values.
- avg(): returns average of all values in a collection.
- count(): returns no of counts from a collection of values.
User Defined
Function