Darling Data/Learn T-SQL With Erik

  • $500
  • $59/mo or $199/yr

Learn T-SQL With Erik

  • Course
  • 250 Lessons

This course is all about T-SQL. You'll learn how to write queries that return correct results, and don't make the server break down when they run. This material spans beginner to advanced, and includes concepts applicable to transactional and reporting workloads. Whether you're designing the next super high concurrency application, or working as a data scientist, engineer, or analyst, this course is for you.

Contents

Course Introduction - 6 minutes
Preview
Environment Setup - 6 minutes
Reference Script Explanation - 7 minutes
01 Course Instructions.sql
03 Common T-SQL Usage And Functions.sql
02 Common T-SQL Conventions.sql
04 Data Storage.sql

Starting T-SQL Querying: Reading Data

Look, we've all been there. You write what seems like a perfectly reasonable query, hit F5, and then... nothing happens. Or worse, everything happens, including your phone blowing up with angry users.

This course will teach you how T-SQL actually works, not just how the docs say it works. Designed specifically for folks bridging the gap from novice to intermediate, you'll learn to write queries that don't make your server cry or your users wonder if they've made a huge mistake.

I've packed over 24 hours of streaming video content (complete with scripts and slides!) with all the stuff I wish I'd known when I first opened SQL Server Management Studio back in 2008. This treasure trove works with SQL Server 2016+, Azure SQL Database, and Azure SQL Managed Instance.

What's on the menu? All the fundamentals explained in plain English:

  • The SELECT statement that does more than just "select everything"

  • JOINs that actually make sense (and don't accidentally create cartesian products)

  • Subqueries and table expressions that solve problems instead of creating them

  • Window functions without the headache

  • Basic transactions that don't lock up the entire database

  • Data modifications that don't leave your tables looking like abstract art

Perfect for folks who know enough T-SQL to be dangerous (to their own servers) but want to level up to the kind of queries that make your DBA send you thank-you notes instead of passive-aggressive monitoring alerts.

You'll gain insights into relational theory, query optimization, and set-based thinking – all explained like you're a human, not a computer.

Ready to write T-SQL that doesn't make users wonder if they've made a huge mistake?

Let's do this!

SELECT FROM WHERE: Lecture - 11 minutes
SELECT FROM WHERE: Demos - 16 minutes
SELECT FROM WHERE.sql
WHERE, HAVING, and Conditional Aggregates - 18 minutes
WHERE and Having.sql
Join Introduction: Lecture - 8 minutes
Join Introduction: Demos - 15 minutes
00 Joins.sql
Cross Join Basics: 10 minutes
01 Cross Joins.sql
Inner Joins Basics - 17 minutes
02 Inner Joins.sql
Outer Join Basics: 23 minutes
03 Outer Joins.sql
Apply Basics: Introduction and TOP N Per Group - 20 minutes
Apply Basics: The VALUES Clause - 12 minutes
APPLY.sql
DISTINCT - 26 minutes
DISTINCT.sql
Group By Part 1 - 17 minutes
Group By Part 2 - 15 minutes
GROUP BY.sql
Order By Introduction - 15 minutes
ORDER BY.sql
Order By and Index Design - 15 minutes
02 Index Sortables.sql
TOP and OFFSET FETCH - 31 minutes
TOP and OFFSET FETCH.sql
CASE Expressions - 26 minutes
00 CASE Expressions.sql
Defensive CASE Expressions - 21 minutes
01 Defensive CASE Expressions.sql
Subqueries - 21 minutes
Subqueries.sql
EXISTS and NOT EXISTS - 25 minutes
EXISTS and NOT EXISTS.sql
Derived Tables - 18 minutes
Derived Tables.sql
Common Table Expressions - 26 minutes
Common Table Expressions.sql
Recursive Common Table Expressions - 23 minutes
Recursive Common Table Expressions.sql
Window Function Basics - 35 minutes
Window Functions.sql
Window Functions: Solving Common Problems - 25 minutes
Window Function Problem Solvers.sql
Grouping Sets, Cube, and Rollup - 20 minutes
Grouping Sets, Cube, Rollup.sql
Pivot and Unpivot - 22 minutes
Pivot and Unpivot.sql
Union and Union All - 15 minutes
01 The Unions.sql
Intersect - 19 minutes
02 INTERSECT.sql
Except - 14 minutes
03 EXCEPT.sql
Distinct From - 21 minutes
04 DISTINCT FROM.sql
NULLs and Datatypes - 27 minutes
NULLs, Data Types.sql
SARGability - 18 minutes
SARGability.sql

Starting T-SQL Querying: Data Modifications

In this section we'll cover data modifications in T-SQL:

  • INSERT

  • Identity

  • Sequence

  • DELETE

  • TRUNCATE

  • UPDATE

  • MERGE

  • OUTPUT

Insert Basics - 21 minutes
01 Insert.sql
Identity Basics - 24 minutes
02 Identity.sql
Sequences Basics - 16 minutes
03 Sequences.sql
Delete and Truncate Basics - 18 minutes
01 Delete and Truncate.sql
Update Basics - 20 minutes
01 Update.sql
Merge Basics - 20 minutes
01 Merge.sql
Output Basics - 23 minutes
01 Output.sql

Starting T-SQL Querying: Transactions and Isolation Levels

Very few areas of databases in general, but SQL Server in particular, suffer as many misconceptions and outright misinformation as these. Developers seem to maintain these nagging mental injuries, like row versioning isolation levels allow dirty reads, or locking isolation levels guarantee snapshot-type consistency of reads, that are simply wrong. In these modules, I'm going to show you the truth.

A.C.I.D. Basics - 15 minutes
00 A.C.I.D..sql
Transaction Basics - 20 minutes
01 Transactions.sql
Isolation Level Basics (Lecture) - 22 minutes
02 Isolation Levels.sql
Serializable Basics - 13 minutes
03 Serializable.sql
Deadlocks Lecture - 10 minutes
Deadlock Demos - 22 minutes
05 Deadlocks.sql
Read Uncommitted and NOLOCK - 21 minutes
06 Read Uncommitted.sql
Locking vs Row Versioning Read Committed - 16 minutes
07 Locking vs Versioning.sql
Read Committed Inconsistencies Part 1 - 10 minutes
Read Committed Inconsistencies Part 2 - 15 minutes
07a Read Committed Iconsistency.sql
Selects That Block and Deadlock - 24 minutes
07b Read Committed Blocking and Deadlocking.sql
Read Committed Concurrency Phenomena - 13 minutes
07c Read Committed Oddity.sql
RCSI and Modifications - 17 minutes
07d Read Committed Snapshot Isolation.sql

Starting T-SQL Querying: Programmability

SQL is for queries, not programming! Well, kind of. Turns out, you can do a lot whole of procedural programming in your declarative language. In these modules, I'll cover all the major types of modules you can create, along with things like cursors, loops, control-flow logic, dynamic SQL, and temporary objects. Get ready for fun.

00 Programmability.sql
Declared Variables - 21 minutes
01 Declared Variables.sql
Control Flow Logic - 14 minutes
02 Control Flow.sql
WHILE Loops - 15 minutes
03 While Loops.sql
Cursor Basics - 21 minutes
04 Cursors.sql
Dynamic SQL Basics - 31 minutes
05 Dynamic SQL.sql
Temporary Objects - 31 minutes
06 Temporary Tables.sql
Error and Transaction Handling Basics - 28 minutes
07 Error Handling.sql
Views and Indexed Views - 32 minutes
08 Views and Indexed Views.sql
Triggers - 25 minutes
09 Triggers.sql
Scalar UDFs - 25 minutes
10 Scalar UDFs.sql
Multi-Statement Functions - 16 minutes
11 Multi-Statement Functions.sql
Inline Table Functions - 24 minutes
12 Inline Functions.sql
Stored Procedures - 30 minutes
13 Stored Procedures.sql

Advanced T-SQL Querying

If you've completed Starting T-SQL Querying, or you're already ahead of the game, this course will bring you from intermediate to advanced. You'll be writing the kinds of queries that astound and amaze.

Let's face it - anyone can write a query that returns results... eventually. But you're ready to go beyond "it works" to "holy cow, how did you do that so fast?!"

This advanced course dives deep into the dark arts of query optimization and techniques that separate the SQL pros from the SQL posers. We're talking about the stuff that makes other developers stare at your code in silent awe (or possibly confusion, but we'll call it awe).

Over 24+ hours of hard-earned wisdom, I'll share:

  • Query plan analysis that reveals what SQL Server is actually doing behind the scenes

  • Index strategies that turn table scans into precision strikes

  • Advanced join techniques that make complex data relationships look simple

  • Memory optimization tricks that keep your server purring instead of paging

  • Query rewrites that can turn minutes into milliseconds

  • Real-world optimization case studies where I've turned database dumpster fires into finely-tuned machines

We'll focus heavily on the written query - because even with the fanciest hardware in the world, a poorly written query can bring a server to its knees. And let's be honest, blaming the hardware is getting old, isn't it?

Compatible with SQL Server 2016+, Azure SQL Database, and Azure SQL Managed Instance, this course builds on the foundation you've established and takes your T-SQL skills to levels that might make your coworkers slightly uncomfortable.

Ready to become the query performance hero your database deserves? Let's write some seriously impressive T-SQL.

Advanced Course Introduction - 15 minutes
00 Intro.pdf

Execution Plan Red Flags

In this section, I'll be covering how written query forms impact query shapes in often unfortunate ways.

Query Plans - 21 Minutes
01 Query Plans.sql
Local Variables - 23 minutes
01 Local Variables.sql
Table Variables - 22 minutes
02a Table Variables.sql
02b Table Variables.sqlplan
Multi-Statement Table Valued Functions - 9 minutes
03 MSTVFs.sql
Scalar User Defined Functions - 24 minutes
04a UDFs.sql
04b UDFs.sqlplan
Eager Index Spools - 23 minutes
05 Eager Index Spool.sql
Common Table Expressions - 18 minutes
06 CTEs.sql
Join On OR Clause - 29 minutes
07 Joins On Or.sql
Left Join vs Not Exists - 28 minutes
08 Left Join vs Not Exists.sql
Join on ROW_NUMBER - 24 minutes
09a Join With Row Number.sql
09b Big Grant String Columns.sqlplan
Top Above Scan - 11 minutes
10 TOP above Scan.sql

Data Storage

In this module we'll be covering the details of different storage formats in SQL Server:

  • Heaps

  • Clustered tables

  • Nonclustered Indexes

  • Column Store

  • Partitioned Tables

  • Partitioned Column Store

  • Partitioned Views

  • NULLable columns

Heaps - 22 minutes
01 Heaps.sql
01a Votes Loads MAXDOP 1.sqlplan
01a Votes Loads.sqlplan
Clustered Tables - 16 minutes
02 Clustered Tables.sql
Nonclustered Indexes - 23 minutes
03 Nonclustered Indexes.sql
Column Store Indexes Intro - 23 minutes
Column Store Modifications - 21 minutes
04 Column Store.sql
Row Store Partitioning - 22 minutes
05 Partitioning.sql
05a Partitioning View.sql
Column Store Partitioning - 22 minutes
06 Partitioning and Column Store.sql
07 Partitioned Views.sql
Partitioned Views - 21 minutes

Filtered Indexes, Computed Columns, and Indexed Views

Some specialty data storage that you should probably know about, separate from the stuff covered in the previous modules.

Filtered Indexes: 28 minutes
01 Filtered Indexes.sql
Computed Columns - 35 minutes
02 Computed Columns.sql
Indexed View Maintenance: 23 minutes
03 Indexed View Maintenance.sql
Indexed View Matching: 24 minutes
04 Indexed View Matching.sql
Indexed View Creation: 12 minutes
05 Indexed View Creation.sql
05a Indexed Views Slow With No Indexes.sqlplan
05b Indexed Views Slow With Indexes.sqlplan
05c Slow Index Create.sqlplan
Indexed View Locking: 11 minutes
06 Indexed View Locking.sql

Index Design

These videos focus on aligning and designing queries in index to affect all sorts of useful things. Performance, memory grants, and more!

Index Search and Sort: 37 minutes
01 Index Search And Sort.sql
Memory Grants: 23 minutes
02 Memory Grants.sql
Equality, Sort, Range Indexing: 33 minutes
03 Align and Design an Index.sql
Top N Per Group Strategies: 13 minutes
04 Align and Design a Query.sql
Gatekeeper Index Columns: 17 minutes
05 Align and Design Hard Mode.sqlplan
05 Align and Design Hard Mode.sql
Dealing With Lookups: 27 minutes
06 Align and Design Lookups.sql
Optimizer Nudging Strategies: 21 minutes
07 Align and Design Optimizer Nudging.sql
Missing Index Requests: 14 minutes
08 Missing Index Nonsense.sql

Working With Dates and Time Zones

Oh, you've got data. Date data. Time data. Datetime data. Maybe even Datetime2 data.

In these modules, I'm going to show you horrible things, and how to avoid them.

I'm also going to cover dealing with time zones in a way that won't drive you crazy bananas.

Introduction To Date Handling: 26 minutes
01 Date Work.sql
Date Filtering Part One: 17 minutes
02 Date Math Filtering Part One.sql
Date Math Filtering Part 2: 26 minutes
03 Date Math Filtering Part Two.sql
Time Zones: 40 minutes
04 Time Zones.sql

Query Optimization

These modules seek to further tie the query you write to the plan and performance that you get. We'll be covering an array of important topics around making queries go faster by changing the way queries are written, tricks for making queries more Batch Mode friendly, and the all-important row goal.

Early Aggregates: 22 minutes
01 Early Aggregates.sql
Multiple Distinct Aggregates: 23 minutes
02 Multiple Distinct Aggregates and Batch Mode.sql
02 Multiple Distinct Aggregates and Batch Mode.sqlplan
Nested Loops Prefetching: 22 minutes
03 Nested Loops Prefetching.sql
03 Nested Loops Prefetching.sqlplan
Distinct Aggregate Limitations: 15 minutes
04 Counting Distinct Groups.sql
Implied Predicate: 11 minutes
05 Implied Predicates.sql
Multi Seeks: 20 minutes
06 Slow Multi Seeks.sql
Union vs Union All: 21 minutes
07 U vs U All.sql
Lazy Table Spools: 23 minutes
08 Table Spools.sql
CASE Expressions: 27 minutes
09 Case Expressions.sql
09 Case Expressions.sqlplan
10a Serially Parallel Seriously Skewed.sqlplan
10 Serially Parallel.sql
10b Serially Parallel Exchange Spill.sqlplan
Parallel Skew: 45 minutes
How To Think Like A Batch Mode: 35 minutes
11 Think Like a Batch.sql
Row Goal Intro: 26 minutes
12 Row Goal Intro.sql
13 Row Goal Action.sql
Row Goals In Action: 30 minutes