T-SQL Fundamentals, 4th Edition

Book description

Starting with the background to T-SQL querying and programming, including: logical query processing, book-querying constructs (single table queries, joins, subqueries, table expressions, set operators, data analysis), data modifications, temporal tables, transactions and concurrency, SQL Graph (completely new to this edition), as well as programmatic T-SQL constructs. The book includes extensive exercises and solutions with explanations, allowing the reader to practice what they've learned.

This book is widely considered as the authoritative guide on T-SQL fundamentals. It focuses on understanding why things work the way they do, and not just how to make them work. When people understand the "why" the code they write tends to be more correct and more meaningful. This edition of the book includes coverage of the newest T-SQL additions up to and including SQL Server 2022.

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Pearson’s Commitment to Diversity, Equity, and Inclusion
  5. Dedication Page
  6. Contents at a Glance
  7. Table of Contents
  8. Acknowledgments
  9. About the author
  10. Introduction
    1. Who Should Read This Book
    2. Organization of This Book
    3. System Requirements
    4. Code Samples
    5. Errata & Book Support
    6. Stay in Touch
  11. Chapter 1. Background to T-SQL querying and programming
    1. Theoretical background
    2. SQL Server architecture
    3. Creating tables and defining data integrity
    4. Conclusion
  12. Chapter 2. Single-table queries
    1. Elements of the SELECT statement
    2. Predicates and operators
    3. CASE expressions
    4. NULLs
    5. The GREATEST and LEAST functions
    6. All-at-once operations
    7. Working with character data
    8. Working with date and time data
    9. Querying metadata
    10. Conclusion
    11. Exercises
    12. Solutions
  13. Chapter 3. Joins
    1. Cross joins
    2. Inner joins
    3. More join examples
    4. Outer joins
    5. Conclusion
    6. Exercises
    7. Solutions
  14. Chapter 4. Subqueries
    1. Self-contained subqueries
    2. Correlated subqueries
    3. Returning previous or next values
    4. Using running aggregates
    5. Dealing with misbehaving subqueries
    6. Conclusion
    7. Exercises
    8. Solutions
  15. Chapter 5. Table expressions
    1. Derived tables
    2. Common table expressions
    3. Views
    4. Inline table-valued functions
    5. The APPLY operator
    6. Conclusion
    7. Exercises
    8. Solutions
  16. Chapter 6. Set operators
    1. The UNION operator
    2. INTERSECT operator
    3. The EXCEPT operator
    4. Precedence
    5. Circumventing unsupported logical phases
    6. Conclusion
    7. Exercises
    8. Solutions
  17. Chapter 7. T-SQL for data analysis
    1. Window functions
    2. Pivoting data
    3. Unpivoting data
    4. Grouping sets
    5. Time series
    6. Conclusion
    7. Exercises
    8. Solutions
  18. Chapter 8. Data modification
    1. Inserting data
    2. Deleting data
    3. Updating data
    4. Merging data
    5. Modifying data through table expressions
    6. Modifications with TOP and OFFSET-FETCH
    7. The OUTPUT clause
    8. Conclusion
    9. Exercises
    10. Solutions
  19. Chapter 9. Temporal tables
    1. Creating tables
    2. Modifying data
    3. Querying data
    4. Conclusion
    5. Exercises
    6. Solutions
  20. Chapter 10. Transactions and concurrency
    1. Transactions
    2. Locks and blocking
    3. Isolation levels
    4. Deadlocks
    5. Conclusion
    6. Exercises
  21. Chapter 11. SQL Graph
    1. Creating tables
    2. Querying data
    3. Data modification considerations
    4. Conclusion
    5. Exercises
    6. Solutions
    7. Cleanup
  22. Chapter 12. Programmable objects
    1. Variables
    2. Batches
    3. Flow elements
    4. Cursors
    5. Temporary tables
    6. Dynamic SQL
    7. Routines
    8. Error handling
    9. Conclusion
  23. Appendix: Getting started
    1. Getting started with Azure SQL
    2. Installing a SQL Server box product
    3. Downloading and installing SQL Server Management Studio
    4. Downloading source code and installing the sample database
  24. Index
  25. Code Snippets

Product information

  • Title: T-SQL Fundamentals, 4th Edition
  • Author(s): Itzik Ben-Gan
  • Release date: April 2023
  • Publisher(s): Microsoft Press
  • ISBN: 9780138101930