Home / Computer Science / SQL Server / Mastering SQL Server: A Comprehensive Guide to Functions and Operations

Mastering SQL Server: A Comprehensive Guide to Functions and Operations

In SQL Server, there are various functions that can be used to manipulate data and perform operations on it. In this blog we discuss about SQL Server functions and operations. These functions can be divided into several categories:

Scalar functions:

These functions return a single value based on the input provided. Examples of scalar functions include DATEPART(), UPPER(), and CONCAT().

  • LOWER(), UPPER()
  • SUBSTRING(), REPLACE()
  • LEN(), DATALENGTH()
  • CAST(), CONVERT()
  • COALESCE(), NULLIF()
Aggregate functions:

These functions are used to perform calculations on a set of values and return a single value. Examples of aggregate functions include SUM(), AVG(), and COUNT().

  • SUM(), AVG()
  • COUNT(), MAX(), MIN()
  • GROUP BY
Ranking functions:

These functions are used to rank rows within a result set. Examples of ranking functions include ROW_NUMBER(), RANK(), and DENSE_RANK().

  • ROW_NUMBER()
  • RANK(), DENSE_RANK()
  • NTILE()
String functions:

These functions are used to manipulate string values. Examples of string functions include LEN(), LEFT(), and REPLACE().

  • CHARINDEX(), PATINDEX()
  • LEFT(), RIGHT(), LTRIM(), RTRIM()
  • CONCAT(), STUFF(), QUOTENAME()
Date and time functions:

These functions are used to work with date and time values. Examples of date and time functions include GETDATE(), DATEADD(), and DATEDIFF().

  • GETDATE(), CURRENT_TIMESTAMP()
  • DATEPART(), DATEADD(), DATEDIFF()
  • YEAR(), MONTH(), DAY(), HOUR(), MINUTE(), SECOND()
  • DATENAME()
Mathematical functions:

These functions are used to perform mathematical operations. Examples of mathematical functions include ABS(), CEILING(), and FLOOR().

  • ABS(), SIGN()
  • CEILING(), FLOOR(), ROUND()
  • EXP(), LOG(), LOG10(), POWER(), SQRT()
Logical functions:

These functions are used to evaluate logical expressions and return a Boolean value. Examples of logical functions include AND, OR, and NOT.

  • AND, OR, NOT
  • CASE WHEN
  • IIF()

These are just some of the functions available in SQL Server, and they can be combined and nested to perform more complex operations.

In the coming article we discuss each type of functions in detail.

About Santosh Kumar Gadagamma

I'm Santosh Gadagamma, an Experienced Software Engineer passionate about sharing knowledge in technologies like Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts, and all levels of software design, development, deployment, and maintenance. I believe computers are essential for the world's functioning, and I'm committed to helping others learn the skills they need to succeed in tech. My website is a valuable learning tool to help you reach greater heights in your education and career, and I believe that education has no end points.

Check Also

Date and Time Functions in SQL Server

Introduction: In the world of databases, managing date and time is a crucial aspect. SQL …