Category Archives: SQL Tutorials

T-SQL is a language used for working with databases on the
MS SQL Server platform. You can find a lot of articles and tutorials about T-SQL in this section. If you want to learn SQL or just read how to work with SQL function you don’t know yet, check out the SQL tutorials. I want every article to contain an example of usage and a code example too

For Beginners – How to Gradually Learn T-SQL

Below, you will find a basic chronological outline that I would recommend following to learn SQL step by step. Use other resources as well to complement and expand your knowledge. If you thoroughly cover these topics, whether here on the website or elsewhere, it will give you a solid foundation for effective work with databases, automation, BI, reporting, applications, and more. You can lay the foundation for:

Before studying, I recommend installing the necessary tools (in this order) so that you can immediately practice the newly acquired knowledge:

1) Introduction to T-SQL – Introduction, Basic Orientation

After studying these articles, you will get acquainted with the basic syntax of the T-SQL language and build simple SQL queries:

2) Basic SQL Clauses (SQL Clauses Category) – Basic Structural Elements of SQL Queries

After studying these articles, you will be able to independently write simple query scripts for one table:

3) Joining Tables (FROM) – Joining

In a relational database, we typically don’t join just one table but several (in the FROM clause). There are several types of table joins. After studying these articles, you will understand the differences between different types of joins and be able to write more complex scripts by joining multiple tables. In practice, understanding and correctly choosing joins in various situations is probably the biggest challenge when learning the SQL language (moving from a complete beginner to moderately advanced):

4) Introduction to SQL Functions (SQL Functions Category)

After understanding the basic structure of the language, you can see how we can work with data (similar to Excel) through functions. These functions are most commonly used in the SELECT clause. Below are a few examples of the most commonly used functions; you can find more in the relevant category on the website:

5) DDL (Creating, Deleting, Cleaning Tables) and DML (Changing Records in Tables)

Until now, we’ve dealt with what’s called DQL (Data Query Language) – querying. After understanding how to query tables, we can move on to creating tables and commands that either modify or delete records in the table:

6) Connecting Data to Excel or Reporting Platforms

If we can prepare data in the database and efficiently query it, we can then pull the query results into tools like Excel or Power BI:

Top 10 Advanced T-SQL Commands for SQL Server Development

This article is a list of commands and techniques for working with SQL Server, which are routine for advanced T-SQL developers. If you are interested in SQL basics, I recommend the SQL tutorials overview. STRING_SPLIT with the “ordinal” parameter for parsing text The newer version of the STRING_SPLIT function, available from SQL Server 2022, extends… Read More »

Bulk Copy Program (BCP) Utility – Fast Bulk Import and Export in SQL Server

BCP is a utility that is installed by default with SQL Server editions and is used for bulk import or export of a large volume of data in user-defined formats. This utility is optimized for large data transfers either between SQL Server instances or between a SQL instance and a text file. The utility is… Read More »

SSRS | How to Create an Amortization Calculator in SQL Server – Including a Report with Parameters

Lately, I’ve been dedicating a lot of time to financial mathematics in Excel. I’ll try to leverage that and shift the focus from Excel to SQL Server. Perhaps someone is considering creating an application for amortization calculator schedule where you can input parameters, and it will generate results for you in a table. The result… Read More »

Facts and Dimensions – Tables in a Data Warehouse

A data warehouse is a central information system designed to store data from one or more enterprise operational systems or other external sources such as Excel, SharePoint, and others. Data in the data warehouse is organized into schemas and undergoes a cleansing and structuring process before storage to make it understandable to users and easily… Read More »

SQLCMD (Server command line) – Run SQL query via cmd

In this short article I will introduce the possibility to run a sql script outside of SQL management studio using SQL server command line utility (sqlcmd for short). This utility allows you to work with SQL server using the command line. The use are obvious and include working with SQL from different applications. How to… Read More »

SQL ALTER TABLE – Syntax, Add, Change Data Type, Delete Column

The ALTER TABLE statement, along with commands like CREATE TABLE, belongs to the category of Data Definition Language (DDL) commands. It allows us to modify the definition of a table. Changes to an SQL Server table can include: Adding a new column Deleting a column Changing the data type or definition of a column Changing… Read More »

SQL Duplicates in a Table with an Example – How to Retrieve a List of Duplicate Values?

In some situations, we need to get an overview of the data present in a table. Or perhaps we want to check if there are any duplicate values in the table that we do not want. How can we retrieve a list of such duplicate records using SQL script? How to Identify Duplicate Rows in… Read More »

SQL Server ROLLUP, CUBE, GROUPING SETS – Totals and Subtotals

What about upgrading GROUP BY clause by use of useful commands? GROUP BY is used in a clause with aggregate operations. When it is used, aggregation happens throughout all columns. Using this simple “grouping” does not enable us to do totals and subtotals. But there is plenty of operators which can easily query for totals.… Read More »

Basic SQL Queries – Overview For Beginners With Examples

What I have here today is a article for beginners. It will be full of sql query examples. We will start from the most basic ones and continue up. SQL queries will be organized chronologically according to their difficulty. I will add more later on. SQL knowledge is a must for any IT department nowadays.… Read More »