Code24Lab
Databases & SQL Intermediate

SQL Server T-SQL in Practice: Joins, CTEs, Procedures & Error Handling

Work through real T-SQL for a fictional parts wholesaler: joins and their traps, variables, CASE, CTEs and recursion, IF and WHILE, stored procedures with OUTPUT parameters, transactions, TRY/CATCH, temp tables, the OUTPUT clause and MERGE, with every answer checked as you go.

22 lessons 22 labs Certificate

  • One-time payment
  • Instant access right after payment
  • Secure checkout with Stripe

About this course

SQL Server T-SQL in Practice takes you from queries to real database code. Working for a fictional spare-parts wholesaler, you predict exactly what T-SQL returns or changes: LEFT JOIN filters in ON versus WHERE, row multiplication across joins, variable assignment, DATEDIFF boundaries, CASE, subqueries and the NOT IN NULL trap, CTEs, ROW_NUMBER and recursive CTEs. Then you trace IF and WHILE logic, call stored procedures with defaults, OUTPUT parameters and return codes, follow transactions and TRY...CATCH, stage data in temp tables, audit changes with the OUTPUT clause and synchronise stock with MERGE. Every answer is checked instantly, and the first lesson is free.

Lessons

  1. T-SQL Query Anatomy: Schemas, TOP and Logical OrderLabFree
  2. INNER vs LEFT JOIN and the ON-versus-WHERE TrapLab Locked
  3. LEFT JOIN + GROUP BY: COUNT, ISNULL and Honest AveragesLab Locked
  4. Three-Table Joins and the Row-Multiplication TrapLab Locked
  5. Variables: DECLARE, SET and SELECT AssignmentLab Locked
  6. Dates in T-SQL: DATEADD, DATEDIFF and EOMONTHLab Locked
  7. CASE and IIF: Turning Rules into ColumnsLab Locked
  8. Subqueries: Scalar, EXISTS and the NOT IN NULL TrapLab Locked
  9. CTE Basics: Name a Step, Use It TwiceLab Locked
  10. ROW_NUMBER in a CTE: Latest per Group and Running TotalsLab Locked
  11. Recursive CTEs: Exploding a Bill of MaterialsLab Locked
  12. Recursive CTEs as Generators: A Calendar of DaysLab Locked
  13. IF...ELSE and BEGIN...END: Control FlowLab Locked
  14. WHILE Loops, BREAK, CONTINUE and @@ROWCOUNTLab Locked
  15. Stored Procedures: Parameters, Defaults and EXECLab Locked
  16. OUTPUT Parameters and RETURN CodesLab Locked
  17. Temp Tables and Table Variables: A Staging ScriptLab Locked
  18. Transactions: BEGIN TRAN, COMMIT, ROLLBACK and @@TRANCOUNTLab Locked
  19. TRY...CATCH, XACT_STATE and Atomic StatementsLab Locked
  20. The OUTPUT Clause: inserted, deleted and Audit TrailsLab Locked
  21. MERGE: Insert, Update and Delete in One StatementLab Locked
  22. Final Project: A Robust Nightly Stock Sync ProcedureLab Locked