Welcome to Queries, Cursors and Views, the second course in our SQL Server Database Implementation series. In Part 1, you learned how to design and create a relational database. In this course (Part 2), you will focus on how applications actually talk to that database: by sending queries, navigating result sets, and exposing data through reusable views.
The examples in this course target SQL Server 2019 and 2022, but the concepts apply directly to Azure SQL Database and SQL Managed Instance. Along the way, you will see how the SQL Server engine has evolved from the SQL Server 2005 era to the modern world of Intelligent Query Processing (IQP), where the optimizer can adapt to your workload in real time.
At a high level:
In SQL Server 2022+, most performance and scalability features assume that you are using set-based queries and well-designed views. Cursors still exist, but you will learn to treat them as a last resort when set-based logic cannot express the business requirement cleanly.
✅ Queries: your primary interface to the engine
SELECT CustomerName, OrderDate
FROM Orders
WHERE OrderDate >= '2025-01-01';
✅ Cursors: row-by-row processing (use sparingly)
DECLARE order_cursor CURSOR FOR
SELECT OrderID FROM Orders;
OPEN order_cursor;
FETCH NEXT FROM order_cursor INTO @OrderID;
WHILE @@FETCH_STATUS = 0
BEGIN
-- process @OrderID here
FETCH NEXT FROM order_cursor INTO @OrderID;
END;
CLOSE order_cursor;
DEALLOCATE order_cursor;
Cursors are easy to understand, but they bypass many of the optimizations that make SQL Server fast. In this course you will often see two solutions to the same problem: a cursor-based version and a set-based version. You will learn to prefer the set-based option whenever possible.
✅ Views: reusable query building blocks
CREATE VIEW ActiveCustomers AS
SELECT CustomerID, CustomerName
FROM Customers
WHERE IsActive = 1;
In later lessons, you will build views that encapsulate business rules and then compare their behavior with equivalent ad-hoc queries, including how the optimizer chooses plans for each.
Between SQL Server 2005 and the current releases, the biggest change is how the engine responds to your workload over time. Modern versions (SQL Server 2019, 2022, and the SQL Server 2025 family) include Intelligent Query Processing (IQP), a set of features that make queries more “self-healing.”
Examples you will encounter in this course include:
IQP focuses on queries and views. Cursors benefit only indirectly (for example, when the cursor’s inner query uses a multi-statement table-valued function that can be optimized with interleaved execution). This is one reason Module 2 compares batch queries vs single queries: you will see how sending work to the server in well-designed batches allows the optimizer and IQP features to do their best work, while cursor-based, row-at-a-time approaches often limit those benefits.
After completing this course, you will be able to:
INSERT, DELETE, UPDATE, and SELECT statements that retrieve and modify data safely and efficiently.You will interact with SQL Server in two ways:
Lessons combine code samples, diagrams, and guided exercises so you can see how a design decision at the T-SQL level shows up as a performance characteristic inside the engine.
Older exams like 70-029 and 70-761 focused on T-SQL syntax and database design for specific SQL Server versions. Today, Microsoft uses role-based certifications instead. If you are studying this course as part of a career plan, you will usually be choosing between:
Choose DP-300 if your primary goal is: “I want to manage and secure Azure SQL instances.” It emphasizes:
DP-300 expects you to understand how queries, views, and (occasionally) cursors affect performance. It is less about writing new T-SQL from scratch and more about diagnosing why a given workload runs slowly and how to fix it.
If you build analytics solutions on Microsoft Fabric and spend most of your time in data warehouses, star schemas, and semantic models, then DP-600 may be the better fit. It focuses on:
From the perspective of this course:
| If your goal is… | Then focus on… |
|---|---|
| Manage, secure, and tune Azure SQL databases. | DP-300 – Azure database administration and engine behavior. |
| Design analytics models and SQL-based transformations in Fabric. | DP-600 – Fabric Analytics Engineer. |
| Deepen T-SQL query skills beyond what exams cover. | This course + advanced T-SQL and performance resources (no single exam). |
As you work through the modules on queries, cursors, and views, keep your long-term direction in mind: DP-300 if you want to become a database-centric engineer, DP-600 if you see yourself building analytics and semantic models on top of SQL.
In this introductory module, you will build a mental model of how queries, cursors, and views interact inside the SQL Server engine. In Module 2, you will compare and contrast batch queries vs single queries in SQL Server 2019 and later, and see how those choices impact locking, concurrency, and Intelligent Query Processing.
In the next lesson, we will review the prerequisites for this course and ensure that your SQL Server or Azure SQL environment is ready for hands-on practice.