In Module 1, you were introduced to queries, cursors, and views at a conceptual level: what they are, why they exist, and how they fit into the SQL Server ecosystem. Module 2 now moves from that high-level orientation into the practical details of how queries actually run inside SQL Server.
This module focuses on SQL query basics with SQL Server 2019 and 2022. You will learn how individual statements are parsed, compiled, and executed, how SQL Server treats single queries versus batches of queries, and how those choices affect performance, error handling, and transaction control. We will also introduce concepts such as system catalogs, logic inside queries, and dynamic SQL, which you will build on in later modules.
Some examples will feel familiar if you have used SQL Server before, but the goal of this module is to give you a clean, modern foundation that supports the more advanced topics to come, including cursor behavior, view design, and business rule implementation.
Every interaction with SQL Server is ultimately a batch of T-SQL statements, even if that batch contains only a single statement. However, from an application design perspective, it is helpful to distinguish between:
In this module you will see scenarios where sending a single statement per round trip is acceptable, and others where combining statements into a batch is essential for both performance and correctness. You will also see how the engine’s modern features—such as Intelligent Query Processing (IQP)—interact with batches and single statements.
A key takeaway as you move into later lessons: whenever possible, design your solutions so that set-based, batched operations do the heavy lifting, and avoid row-by-row processing from the client unless there is a clear reason to do so.
While detailed view design is covered later in the course, it is important at this stage to understand how views relate to query basics.
In SQL Server, a view is a named query stored as a database object. Views:
SELECT, but generally do not store data themselves.
In Module 2, you will mainly consume views as query targets (for example,
SELECT ... FROM SalesSummaryByMonth) while focusing on how SQL Server executes those queries.
Later modules will teach you how to design and maintain views as part of a larger logical model.
After completing this module, you will be able to:
sp_executesql, how to parameterize dynamic statements, and how to avoid SQL injection.As you work through query examples, keep these view characteristics in mind:
SELECT statement.You can think of a view as a reusable building block: a way to define a common query once and then reference it consistently throughout your code base.
Some topics in this module build on ideas you may only have seen briefly so far, such as:
IF, WHILE, and CASE)You do not need to master all of those topics before starting this module, but you should be comfortable reading simple T-SQL statements and understanding what a query does at a basic level.
One of the most important shifts in thinking is moving from a procedural, row-by-row mindset to a set-based mindset. Many developers come from languages where you write loops and process one record at a time. SQL Server can support that style using cursors and loops, but it is not where the engine excels.
In this module, I will challenge you to:
By the end of Module 2, you will have a stronger understanding of how queries behave, how batches differ from single statements, and how views participate in query execution. This foundation will prepare you for the later modules on cursors, advanced view design, and more sophisticated enterprise business rules.
In the next lesson, you will learn the practical steps for executing your queries and inspecting the results.