Upto 20% Scholarship on Live Online Classes

- Technology Blogs -

Different Types of SQL Server & SQL Database Functions

  • »
  • Blog
  • »
  • SQL
  • »
  • Different Types of SQL Server & SQL Database Functions

SQL Server Functions:

  • It is a database object in sql server.
  • By using functions, we can do complex arithmetical operations and programing.
  • Supports only SELECT or read data.
  • We cannot use function to Insert/Update/Delete records in the database table.
  • We can use variables and cursors.
  • It accepts only input parameters, do not have output parameters.
  • We can call User Defined Functions as part of Select/Insert/Update/Delete.
  • It can be nested up to 32 level.
  • UDF can have up to 1023 input parameters.
  • It can’t return XML data type.
  • It doesn’t support Exception handling.

Types of SQL Server Functions:

  • System Defined Functions

And in system defined function we have 2 types of functions.

  • System Scalar Function
  • System Aggregate Function

Scalar Functions: Which operators on single value and returns single value, below is the list of some scale functions used in sql server.

Scalar Function Description
round (9.56785) This will round the give number to 3 places of decimal, 9.567
rand (10) This will generate random numbers of 10 characters
upper (‘sql’) This will return upper case of given string, ‘SQL’
lower (‘SQL’) This will return lower case of given string, ‘sql’
abs (-20.75) This will return absolute number of a given number, 20.25
Convert (int, 20.56) This will convert given float value to integer, 20
ltrim (‘  sql’) This will remove the spaces from left hand side, ‘sql’
rtrim (‘sql  ‘) This will remove the spaces from right hand side, ‘sql’
Substr () This will extract characters from a text field
ASCII (char_Exp) This will return ASCII code of the given character expression
Read:   What is SQL Server? Microsoft SQL Server Tutorial Guide for Beginners

Read More: Different Type of SQL Joins

Aggregate Functions: Aggregates the values and return a single value, below is the list of some aggregate values in sql server.

Aggregate Function Description
Min () This will return Minimum value
Max() This will return Maximum value
Avg () This will return Average value
Count () This will return number of counts
Sum () This will return total sum of numeric value
  • User Defined Functions

These functions are created by user in the system database, and we have 3 types of user define functions:

  • Scalar Function
  • Inline Table-Valued Function
  • Multi Statement Table-Valued Function

Read More: Different Types of SQL Injection

Scalar Function: It is a function that takes one or more values but returns a single value.

Example: 

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Read More: Different Types of SQL Keys

Inline table-Valued function:

It returns a table variable as a result of actions perform by function. The value of table variable should be derived from a single SELECT statement.

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Read More: SQL Server Interview Questions

Multi-Statement Table-Valued Function

Multi-statement table-valued function returns a table variable as a result of actions perform by function. In this a table variable, must be explicitly declared and defined whose value can be derived from a multiple sql statements.

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Types of SQL Server & SQL Database Functions

Kristine

Kristine

I am Kristine, the SQL Server Trainer with JanBask training, I write articles on SQL, its interview questions, its certifciations etc, to help the individuals learn more and more about SQL.



Write a Comment

avatar
  Subscribe  
Notify of

Trending

Top 30 Core Java Interview Questions and Answers for Fresher, Experienced Developer
What Is Trigger In Salesforce?
Top 30 Manual Testing Interview Questions & Answers for Fresher
Different Types of SQL Server & SQL Database Functions
Top 20 AWS Interview Question and Answers For Fresher, Experienced Developer

Related Posts

What Is The Difference Between The SQL Inner Join And Outer Joins?
SQL Server Recovery Models-Simple, Full and Bulk Log
What Is The Difference Between Tables And Views In SQL?
A Definitive Guide to Databases – Oracle vs. SQL Server vs. MySQL
Top 30 Data Modeling Interview Questions with Answers