Functions
Overview of the SQL Median function
January 4, 2023In this article, we will learn how to implement the median functionality and wrap it into a SQL median function
Read more »Understanding the SQL SUM() function and its use cases
December 13, 2022Today, I will describe the SQL SUM () function along with its use cases in this article. There are various mathematical calculations we need to do in day-to-day business requirements. SQL Server offers various system functions which I have listed below to get these mathematical calculations easily by using them. One such requirement is to get the sum of values stored in a numeric column. We can use SQL Server system function SUM () to easily get the sum of the values stored in a numeric column of the table.
Read more »SQL Commands to check current Date and Time (Timestamp) in SQL Server
October 7, 2022This article explores different SQL Commands (functions) to return the current Date and Time (Timestamp) in SQL Server.
Read more »Working with the SQL MIN function in SQL Server
May 12, 2022The SQL MIN function is an aggregate function that is used to find the minimum values in columns or rows in a table.
Read more »Understanding security testing for SQL Server environments
March 3, 2022This article will explain various aspects of security testing for the SQL Server environment. Security is a very critical area for any database environment. We must properly plan, deploy, and audit database security measures to protect and prevent any unauthorized access of the data. We should also perform regular security testing to ensure we have the right set of rules and policies in place to secure our database environment. Database security measures also help any organization to protect its data to maintain its privacy and integrity.
Read more »Getting started with SQL Server CLR functions
January 11, 2022This article will explain how to create a SQL Server CLR function stored in a C# class library without creating a SQL Server database project. We will first briefly explain the concept of .NET common language runtime (CLR) and then build a C# class library using the .NET framework. Then, we will use the C# library to create user-defined CLR functions in SQL Server.
Read more »SQL Server GETDATE () function and its use cases
December 16, 2021This article will discuss an overview and use cases of the SQL Server GETDATE () function which is used to return the current date and time of the system on which SQL Server instance is running. There are several date-time related functions in SQL Server for distinct requirements like SYSDATETIME, CURRENT_TIMESTAMP, etc. All these functions will return the current date-time of the system on which the SQL Server is running. The only difference of having these many functions is the accuracy of the length of timestamp like till what precision you want to return your date time output. I will show you the output of some of these date-time functions and compare them with SQL Server GETDATE () function.
Read more »Understanding the SQL MIN statement and its use cases
December 3, 2021Today, I will explain an overview of the SQL MIN () function along with its several use cases in this article. This function is categorized under aggregate functions in SQL Server. Aggregate functions perform a calculation on a set of values from a specified expression and return a single value in their output. Aggregate functions return the same value every time you execute them unless your source data is changed.
Read more »An overview of Analytic Functions in SQL Server
August 2, 2021In this article, we are going to talk about the various analytic functions that are supported by the SQL Server Database Engine. As it goes by the name, these are some special functions using which we can execute analytic queries on the dataset and obtain useful results. In comparison to standard SQL queries, sometimes it becomes necessary for the Data Analysts to deep dive into the data more and obtain insights from analytic perspectives. This article will discuss all the analytic functions supported by SQL Server with some details.
Read more »Working with SQL NULL values
May 19, 2021This article will explain what problems can occur when working with SQL NULL values and it also gives some solution recommendations to overcome these issues.
Read more »Scalar UDF Inlining in SQL Server 2019
September 28, 2020In this article, we will explore a new SQL Server 2019 feature which is Scalar UDF (scalar user-defined) inlining. Scalar UDF inlining is a member of the intelligent query processing family and helps to improve the performance of the scalar-valued user-defined functions without any code changing.
Read more »How to parse JSON in SQL Server
September 15, 2020In this article, we will learn how to parse and query JSON in SQL Server with the help of the OPENJSON function. Firstly, we will briefly look at the data structure of the JSON and then we will learn details of the parsing and querying JSON data using the OPENJSON function.
Read more »Different ways to search for objects in SQL databases
June 29, 2020This article explores various ways to search for database objects in SQL database such as tables, stored procedures, functions, and views.
Read more »Execute a SQL Server procedure inside a function
June 23, 2020In this article, we will ensure that the execution of the SQL Server procedure inside the function is possible. A common understanding of the database developer is that the procedure cannot be utilized or executed inside a user-defined function because the user-defined function does not allow performing DML operation with the table. The procedure is allowed to play with the database and its property, whether a user-defined function isn’t. That should be the essential reason behind allowing the execution of a SQL Server procedure inside the function.
Read more »Learn SQL: Intro to SQL Server loops
June 15, 2020Loops are one of the most basic, still very powerful concepts in programming – the same stands for SQL Server loops. Today, we’ll give a brief info on how they function and introduce more complex concepts in upcoming articles of this series.
Read more »Calling an AWS Lambda function from another Lambda function
June 9, 2020In this article, I am going to explain how to create an AWS Lambda function and then call this function from another Lambda function within the same region. This is a useful scenario in which we may need to execute a second lambda function based on the outcome of some previous logic. Another scenario may be to execute a second lambda function several times by using different parameters.
Read more »Lever T-SQL for Pinpoint Control of ORDER BY in a Stored Procedure
June 1, 2020Introduction
The T-SQL ORDER BY clause sorts SQL Server SELECT statement result sets, and it becomes important when we build stored procedures. Unfortunately, the syntax offers no flexible way to directly control the ORDER BY clause behavior with argument values. This means we don’t have an easy way to control the specific column or columns that the ORDER BY clause sorts. Additionally, SQL Server does not offer a flexible way to directly control the ascending or descending order of any ORDER BY clause column with argument values. Of course, we can certainly hard-code the ORDER BY clause in a stored procedure, but this approach becomes fixed in stone. We could try a dynamic SQL solution, involving a stored procedure code that dynamically builds and executes SQL Server statements inside a stored procedure. However, this technique becomes tricky, and it can lead to SQL injection attacks. Other techniques might rely on CASE statements, and their complexity can become overwhelming as the column count grows. This article spotlights a clean, efficient, pinpoint T-SQL stored procedure technique that directly sorts one, some, or all SELECT statement result set columns. The technique avoids dynamic SQL, and it operates directly in a stored procedure. The article also shows how to set the ascending or descending sort order of specific columns.
Read more »Explore the DATABASEPROPERTYEX() function for SQL Server databases
May 28, 2020In this article, we explore a SQL function to extract SQL database metadata using the DATABASEPROPERTYEX function.
Read more »Lever T-SQL to dynamically define duplicate SQL Server database table rows
May 11, 2020Introduction
Lever T-SQL to handle duplicate rows in SQL Server database tables article highlighted T-SQL features that detect and handle duplicate SQL Server table rows. The techniques work well, but they rely on fixed duplicate row definitions. This article extends those techniques, showing how to define duplicate rows in a dynamic way.
Read more »Memory-Optimized Table Variables in SQL Server
May 6, 2020This article will cover the usage details and performance advantages of the memory-optimized table variables.
Read more »Lever T-SQL to handle duplicate rows in SQL Server database tables
April 24, 2020Duplicate rows in a SQL Server database table can become a problem. We will see how we can find and handle those duplicate rows using T-SQL in this article.
Read more »Pagination in SQL Server
April 14, 2020Pagination is a process that is used to divide a large data into smaller discrete pages, and this process is also known as paging. Pagination is commonly used by web applications and can be seen on Google. When we search for something on Google, it shows the results on the separated page; this is the main idea of the pagination.
Read more »Solve Time Zone, GMT, and UTC problems using the T-SQL Toolbox database
March 23, 2020Introduction
Soon enough, the applications and database software we build will handle date and time values. The T-SQL Toolbox database – a free download – can help solve complex calculations with those values.
Read more »SQL Server multi-statement table-valued functions
September 11, 2019In this article, we will learn multi-statement table-valued functions (MSTVFs) basics and then we will reinforce our learnings with case scenarios.
Read more »