CRUD Operations used in SQL-Server 2025 Summary
Lesson 1 opened with a promise: everything Module 2 built, the ADO.NET commands, the Entity Framework Core DbContext, had been quietly relying on SQL underneath without ever asking anyone to write it directly. This module closed that gap, one statement at a time. Seven lessons later, every one of the four statements that read and change a table's data has been written by hand, run directly in Azure Data Studio against VirtualBookShelf's own Customer and Inventory tables, and then compared side by side with the ADO.NET and Entity Framework Core code that sends the same statement underneath.
This page pulls those seven lessons together: what each one covered, how the four statements relate, and where the data actually stands right now after everything this module did to it.
The Seven Lessons, in Order
Lesson 1: Basic SQL Queries
Defined what a database actually is, structured and persistent data managed by a DBMS, drew the line between declarative SQL and the procedural, row-by-row thinking the old VBScript
Recordset approach relied on, and previewed the four statements the rest of this module builds around:
SELECT,
INSERT,
UPDATE, and
DELETE.
Lesson 2: SQL SELECT Statement
Wrote the simplest possible
SELECT, naming columns or using the asterisk wildcard to retrieve every row from a single table, with no filtering and no sorting yet.
SELECT BookID, Title, Author FROM Inventory; is the sentence everything else in this module builds on top of.
Lesson 3: SQL WHERE Clause
Narrowed that plain
SELECT down to specific rows: comparison and logical operators,
BETWEEN for a range,
IN for a set of values,
LIKE for a text pattern, and
IS NULL/
IS NOT NULL for the rows a plain equals sign can never match. This lesson is also where parameterized queries stopped being an abstract warning and became a concrete line of ADO.NET code,
@Author standing in for whatever a customer actually types into a search box.
Lesson 4: ORDER BY Clause
Added control over the order a result set comes back in: ascending by default,
DESC for descending, multiple columns to break ties, and
OFFSET/
FETCH for returning one page of a sorted list at a time, the same mechanism
Skip() and
Take() stand in for on the Entity Framework Core side.
Lesson 5: UPDATE Statement
Moved from reading data to changing it:
SET for the new values,
WHERE to limit which rows change, compound assignment operators as shorthand for a common pattern, and the
OUTPUT clause for capturing a row's before and after values from a single statement.
Lesson 6: INSERT Statement
Added brand new rows: a column list, a matching
VALUES list, letting an
IDENTITY column generate its own primary key rather than assigning one by hand, and a multi-row
VALUES list for adding several rows in one atomic statement.
Lesson 7: DELETE Statement
Closed the loop by removing rows: the same danger a missing
WHERE clause poses for
UPDATE, archiving a row with
OUTPUT ... INTO before it's gone for good, and the real differences between
DELETE and
TRUNCATE TABLE.
Where VirtualBookShelf's Data Actually Stands Right Now
These lessons didn't just describe SQL in the abstract; they ran real statements against VirtualBookShelf's real tables, and those statements left a trail worth tracing. Inventory started this module with six books. Lesson 6's multi-row INSERT added three more, "Midnight Harbor," "Garden Almanac," and "Pocket Astronomy," bringing the total to nine. Lesson 7 then removed "Midnight Harbor" after it sold poorly, the exact kind of discontinued-title cleanup this module opened by describing in the abstract. Inventory currently holds eight books, and its IDENTITY column remembers that BookID 7 was used and released; the next book inserted gets BookID 10, not a recycled 7.
Customer saw a comparable, smaller-scale change: Lesson 6's single-row INSERT example added William Rogers, by letting SQL Server generate his CustomerID automatically rather than assigning one by hand, exactly the identity-column pattern Inventory relies on too. Nothing in this module altered either table's actual structure. Module 2, Lesson 2 designed Customer and Inventory once; every statement since has read from and written to those same two tables, unchanged.
It's worth being precise about what "unchanged" means here, since this module came close to touching the schema itself more than once. Lesson 6 deliberately left CustomerID and BookID out of every INSERT statement's column list, rather than assigning values by hand, specifically because both are IDENTITY columns Module 2 already defined that way. Lesson 7 considered, and rejected, using TRUNCATE TABLE for anything in this module, specifically because resetting Inventory's identity counter back to 1 would have erased the very history this section just traced. Every statement in this module worked within the schema Module 2 built, never around it.
The Full Cycle, Three Ways
Every lesson in this module compared its one statement across raw SQL, ADO.NET, and Entity Framework Core. Strung together, those four statements form a complete lifecycle for a single row, from the moment it's created to the moment it's removed, and seeing all four side by side in each of the three forms makes the pattern underneath all of them obvious.
-- Raw SQL: the complete lifecycle of one Inventory row
INSERT INTO Inventory (Title, Author, ISBN, Price, QuantityOnHand)
VALUES ('Pocket Astronomy', 'Chen', '978-1-55555-203-8', 19.95, 14);
SELECT BookID, Title, Price FROM Inventory WHERE Title = 'Pocket Astronomy';
UPDATE Inventory SET Price -= 2.00 WHERE Title = 'Pocket Astronomy';
DELETE FROM Inventory WHERE Title = 'Pocket Astronomy';
// ADO.NET: the same lifecycle, parameterized throughout
using var insertCmd = new SqlCommand(
"INSERT INTO Inventory (Title, Author, ISBN, Price, QuantityOnHand) " +
"VALUES (@title, @author, @isbn, @price, @qty);", connection);
// ... parameters added, ExecuteNonQuery() called
using var selectCmd = new SqlCommand(
"SELECT BookID, Title, Price FROM Inventory WHERE Title = @title;", connection);
// ... ExecuteReader() called
using var updateCmd = new SqlCommand(
"UPDATE Inventory SET Price -= @discount WHERE Title = @title;", connection);
// ... ExecuteNonQuery() called
using var deleteCmd = new SqlCommand(
"DELETE FROM Inventory WHERE Title = @title;", connection);
// ... ExecuteNonQuery() called
// Entity Framework Core: the same lifecycle through change tracking
var book = new Inventory { Title = "Pocket Astronomy", Author = "Chen", /* ... */ };
context.Inventory.Add(book);
context.SaveChanges();
var found = context.Inventory.Single(b => b.Title == "Pocket Astronomy");
found.Price -= 2.00m;
context.SaveChanges();
context.Inventory.Remove(found);
context.SaveChanges();
The raw SQL version is four separate, independent statements. The ADO.NET version parameterizes every single one, never pasting a title or a price directly into the SQL text. The EF Core version never writes
INSERT,
SELECT,
UPDATE, or
DELETE anywhere at all; it creates an object, finds one, changes a property, and removes one, letting
SaveChanges() generate the actual SQL underneath each time. All three accomplish exactly the same thing to exactly the same row. That equivalence is the real lesson of this entire module: the SQL this module taught by hand is the SQL both frameworks have been generating all along.
What's Actually New to SQL Server 2025, and What Isn't
Several features turned up across these seven lessons that sound like they belong to SQL Server 2025 specifically, and sorting out which ones genuinely are is worth doing explicitly, since getting this wrong is an easy, common mistake.
Genuinely new to SQL Server 2025: the native binary json data type and the vector(n) type for AI similarity search, along with functions built specifically around them, including REGEXP_REPLACE for pattern-based text replacement and JSON_CONTAINS() for filtering inside a JSON column. None of these have a foothold in VirtualBookShelf's schema yet, since Customer and Inventory have no JSON or vector columns, but they're real, and they're the actual 2025-specific material in this module.
Older than they might sound: compound assignment operators like -=, used throughout this module's UPDATE examples, have existed since SQL Server 2008. The OUTPUT clause, used for UPDATE, INSERT, and DELETE alike, has existed since SQL Server 2005. JSON_OBJECT() and JSON_ARRAY(), for building a JSON value by hand, date to SQL Server 2022, not 2025. REGEXP_LIKE, used in Lesson 3 and again in Lesson 7, is genuinely new to 2025, alongside REGEXP_REPLACE, so regular expressions as a whole are a real 2025 addition even though some of their neighboring features aren't.
Optimized Locking came up repeatedly, and it deserves its own honest summary: it combines a single lock on a transaction's own ID, rather than many separate row locks, with a technique called Lock After Qualification that checks a row's last committed value against a WHERE clause before locking it, so non-matching rows are never locked at all. Both pieces require accelerated database recovery to be enabled first. None of this changes how any statement in this module is written; it's an improvement SQL Server 2025 applies automatically, underneath statements that look identical to how they'd be written on an older version.
Why Every Lesson Compared the Same Statement Three Ways
It would have been faster to teach raw SQL alone and leave ADO.NET and Entity Framework Core for Module 2 to have covered on their own. This module didn't do that, on purpose, in every single lesson, and the reason is worth stating directly rather than leaving implicit.
A framework that generates SQL automatically is only trustworthy to someone who already knows what SQL it should be generating. Entity Framework Core's context.Inventory.Where(b => b.Price < 25.00) is genuinely convenient, but it's only obviously correct to someone who can already picture SELECT * FROM Inventory WHERE Price < 25.00; without needing EF Core to show it to them first. The three-ways comparison in every lesson wasn't repetition for its own sake; it was proof, lesson after lesson, that the convenient version and the explicit version are always the same statement wearing different syntax, never two separate things that happen to agree by coincidence.
This also explains why the ADO.NET version specifically always used a parameter rather than string concatenation, even in lessons where the value being inserted was a fixed literal with no real injection risk. The habit has to be automatic by the time a value actually does come from a customer's search box or a web form's input field, and a habit practiced only when it's convenient isn't really a habit yet.
A Few Common Questions
Do all four statements, SELECT, INSERT, UPDATE, and DELETE, really share the same WHERE clause rules? Yes, entirely. Every comparison, logical, range, set, and pattern-matching technique Lesson 3 covered works identically whether it's narrowing a SELECT's result set or deciding which rows an UPDATE or DELETE actually touches. Learning WHERE once, thoroughly, in Lesson 3 is what made every later lesson's own WHERE clause require no new explanation at all.
Which of these four statements is the most dangerous to get wrong? DELETE, and specifically a DELETE with no WHERE clause, since it has no built-in undo once it commits. UPDATE without a WHERE clause is a close second, for the same reason. SELECT can never change data no matter how it's written, which is exactly why this module introduced it first and spent two full lessons on WHERE before any statement capable of changing a row appeared at all.
Is raw SQL actually necessary now that ADO.NET and Entity Framework Core both exist? For writing production code day to day, often not directly, EF Core in particular is designed so a working application rarely needs hand-written SQL. But every one of its LINQ queries only generates correct, efficient SQL when the person writing the LINQ understands what SQL statement it should become, which is precisely what this module built, one statement at a time, before either framework was asked to generate anything on its own.
Why did this module always run its raw SQL examples in Azure Data Studio specifically, rather than inside the VirtualBookShelf application itself? Speed and isolation. Typing a statement into Azure Data Studio and pressing Execute gets an answer immediately, with no need to rebuild a Razor Pages project or click through its pages first. It also keeps a mistake contained: a typo in an experimental UPDATE run directly against the database is easy to see and correct on the spot, in a way a bug buried inside application code wrapped around the same statement would not be. Once a statement is confirmed correct this way, moving it into a SqlCommand or a LINQ expression is a small, mechanical step, exactly what every lesson's three-ways comparison demonstrated.
Does this module cover everything SQL Server 2025 can do? Not remotely. Window functions, GROUP BY and aggregation, joining two or more tables together, subqueries, native JSON querying, and vector similarity search all came up as acknowledged but out-of-scope material across these seven lessons, consistently because they either require schema VirtualBookShelf doesn't have yet or build on SQL concepts this module hadn't introduced yet. SELECT, WHERE, ORDER BY, UPDATE, INSERT, and DELETE are the foundation; everything named here builds on top of that foundation rather than replacing any part of it.
What's the single most important habit this module tried to build, beyond the syntax itself? Checking before changing. Lesson 3 introduced the idea of running a WHERE clause as a plain SELECT first; Lesson 5 and Lesson 7 both returned to it explicitly before their UPDATE and DELETE examples. Syntax can be looked up again later. The habit of confirming exactly which rows a statement will touch, before running the version that actually touches them, is worth carrying into every statement written after this module ends, not just the ones inside it.
Why does Inventory's IDENTITY column matter enough to mention twice in this conclusion? Because it's a small detail with a real consequence the first time someone notices it unexpectedly. A gap in a sequence of BookID values, like the missing 7 after Lesson 7's deletion, looks like a bug to someone who doesn't already know IDENTITY never reuses a released value under an ordinary DELETE. Knowing why that gap exists, and that TRUNCATE TABLE is the one statement in this module that would actually reset it, prevents a moment of genuine confusion later, the kind that's easy to mistake for a data-integrity problem when it's really just how the column was always designed to behave.
Could this module's seven lessons have been taught in a different order? Not easily, and the order chosen here matters more than it might look. SELECT had to come before WHERE, since WHERE only makes sense as a refinement of something that already works. WHERE had to come before UPDATE, INSERT, and DELETE, since all three rely on the exact same clause to decide which rows they affect. INSERT came before DELETE specifically so Lesson 7 could remove a row Lesson 6 had just added, rather than reaching for one of the module's original six books. Every lesson in this module depends on something a previous one already established.
What's Ahead
Before moving on, the Module 3 quiz below is worth taking, a short check across all four statements this module covered, SELECT, UPDATE, INSERT, and DELETE, together with the WHERE and ORDER BY clauses that refine them.
Everything built across these seven lessons carries forward unchanged. VirtualBookShelf's Customer and Inventory tables, the connection this course established back in Module 2, and the habit of writing a statement directly before trusting a framework to generate one, all stay exactly as they are. What changes from here is scope: the statements this module covered are the foundation nearly everything else in SQL builds on top of, and the next material in this course builds further on that same foundation rather than replacing any part of it.
Essential SQL - Quiz