T-SQL Tutorial – Learn SQL Server programming

Practical T-SQL tutorial to learn SQL Server programming online, by example and with progressive iterations.

Welcome to our T-SQL tutorial platform, dedicated to IT and SQL Server, with a focus on data management tools! We offer online this SQL tutorial to help our visitors master the SQL language, starting with the basics of T-SQL. Topics cover various operations such as inserting data into a table using INSERT or INSERT INTO, displaying data with a SELECT queries, and creating stored procedures and functions.

It’s important to note that in our examples, the SQL Server version isn’t specifically mentioned. Since SQL language is standardized, most of the functions don’t change between Microsoft DBMS versions. Our examples work on older SQL Server versions like 2008, 2008 R2, and 2012, as well as newer versions like 2016, 2017, 2019, and 2022. You can also apply these operations directly on Azure SQL databases. We’re excited to offer these articles and full tutorial to help you learn SQL Server. However, of course some newer features will only be available on latest versions, this will be mentioned in the post.

Learn SQL Server online with our practical T-SQL tutorial

A Database Management System (DBMS) is a software designed to manage, manipulate, and store data in the form of databases containing tables. It uses SQL code (Structured Query Language) to execute queries to manipulate or display data stored in the databases. T-SQL is the abbreviation for Transact-SQL and it is Microsoft’s SQL programming language tailored for their SQL Server platform.

1. T-SQL Tutorial about the basics

First, simple examples of queries using the SELECT clause for example. Learn also to create some tables.

T-SQL Tutorial about insert into a SQL Server table
T-SQL Tutorial about insert into a SQL Server table

2. Tutorial to manage tables and columns using Transact-SQL

This second section is about to manage tables in a SQL Server database, but also columns within tables. This section contains also articles about Temporary tables and Common Table Expressions (CTE).

3. Insert and update data using T-SQL queries

Next, a section on inserting data with the INSERT clause. Learn data insertion queries with T-SQL. Explore a basic example of an INSERT query in SQL Server, understand the process of inserting data into a table using a SELECT INTO query, and gain proficiency in creating dynamic INSERT INTO queries using SQL Server variables. Learn about the practical implementation of Insert or Update methods, also called Upsert and discover how to update the same column in another line with SQL Server.

4. Manage SQL Server views with scripts

In this third section, learn how to effectively manage SQL Server views with scripts, learn to create a SQL Server view, manage SQL Server views using T-SQL. And also how to modify a SQL Server view, create SQL Server partitioned views, and drop a SQL Server view.

5. Work with SQL Server strings variables and columns

In SQL Server programming, it is important to learn practical aspects of working with strings and text types. From handling various data types to efficiently managing lengthy strings and converting XML to NVARCHAR, we’ll explore essential techniques that simplify database operations. Get ready to enhance your SQL Server skills with insights into string manipulation, variable storage, and the utility of the SUBSTRING function.

T-SQL programming tutorial on managing line breaks in text
T-SQL programming tutorial on managing line breaks in text

6. Manage SQL Server stored procedures

In this section, you’ll acquire the skills to create stored procedures, ranging from simple ones to those with input and output parameters. Stored procedures, as T-SQL code blocks saved on the SQL Server, offer reusability and can be called from any connecting application or program. This procedure section promotes efficient data processing sharing among users, because it is all about reusability. The content will guide you through the creation and management of stored procedures in SQL Server, emphasizing best practices for efficiency and error avoidance.

7. SQL Server Functions

The section number 7 discusses managing SQL Server functions, also called User-Defined Functions to distinguish them from the built-in system functions.

8. SQL Server programming tutorial to manage dates

Explore the topic of T-SQL date and time functions as we delve into practical scripts to manage dates in database. Discover the common pitfalls to handle dates efficiently in T-SQL, like how to calculate the difference between two dates with precision.

9. Work with SQL Server objects metadata

The SQL Server system tables allows to list all the objects from a given database, it is very useful to check if objects exists. But also to list all object very quickly.

10. SQL Server tutorial on managing partitions and indexes

10.1 Partitions tutorial

10.2 Manage indexes using T-SQL

11. T-SQL PIVOT and UNPIVOT operators

In the world of relational databases, it’s common to find data stored as rows. However, sometimes it’s more convenient to work with data organized as columns. SQL Server’s PIVOT and UNPIVOT operators are essential tools for performing this transformation. Using these operators, you can easily convert table data stored in a row layout to a column layout, or vice versa.

Transact-SQL article on how to use the PIVOT operator
Transact-SQL article on how to use the PIVOT operator

12. Manage XML and JSON data types in SQL Server

To continue with more advanced,

13. More advanced T-SQL tutorial

A final word about the T-SQL programming tutorial

In conclusion, our T-SQL programming tutorial provide a valuable opportunity for acquiring skills in database management and manipulation. Explore the basics of SQL and T-SQL language through our online courses, covering tasks such as creating tables, inserting data, querying, filtering, sorting, utilizing aggregation functions, grouping data, and crafting stored procedures and functions.

Our examples cater to various SQL Server versions, both older and newer, enabling you to progress at your own pace on Microsoft’s Database Management System. With our courses, you’ll gain practical expertise, particularly in confidently creating and managing stored procedures in SQL Server. We invite your feedback and suggestions for an enhanced learning experience.