You are previewing Beginning T-SQL 2012.
O'Reilly logo
Beginning T-SQL 2012

Book Description

Beginning T-SQL 2012 is the first step toward learning the T-SQL language that underlies Microsoft's SQL Server database engine. T-SQL is essential in writing SQL statements to get data into and out of a database. T-SQL is the foundation for business logic embedded in the database in the form of stored procedures and functions. Beginning T-SQL 2012 starts you on the path to mastering T-SQL, with an emphasis on best practices and sound coding techniques.

Beginning T-SQL 2012 begins with an introduction to databases, normalization, and to SQL Server Management Studio. Each subsequent chapter teaches an aspect of T-SQL, building on the skills learned in previous chapters. Exercises in each chapter give readers an opportunity for the hands-on practice that leads to true learning and distinguishes the competent professional.

  • Imparts best practices for writing T-SQL

  • Helps you avoid common errors

  • Shows how to write scalable code for good performance

Table of Contents

  1. Title
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. Foreword
  6. About the Authors
  7. About the Technical Reviewer
  8. Acknowledgments
  9. Introduction
  10. Chapter 1: Getting Started
    1. Installing SQL Server Express Edition
    2. Installing the Sample Databases
    3. Using SQL Server Management Studio
    4. Exploring Database Concepts
    5. Summary
  11. Chapter 2: Writing Simple SELECT Queries
    1. Using the SELECT Statement
    2. Filtering Data
    3. Working with Nothing
    4. Performing a Full-Text Search
    5. Sorting Data
    6. Thinking About Performance
    7. Summary
  12. Chapter 3: Using Functions and Expressions
    1. Expressions Using Operators
    2. Using Functions
    3. The TOP Keyword
    4. Ranking Functions
    5. Thinking About Performance
    6. Summary
  13. Chapter 4: Querying Multiple Tables
    1. Writing INNER JOINS
    2. Writing Outer Joins
    3. Writing Subqueries
    4. Writing UNION Queries
    5. Exploring Derived Tables and Common Table Expressions
    6. Thinking About Performance
    7. Summary
  14. Chapter 5: Grouping and Summarizing Data
    1. Aggregate Functions
    2. The GROUP BY Clause
    3. The ORDER BY Clause
    4. The WHERE Clause
    5. The HAVING Clause
    6. DISTINCT
    7. Aggregate Queries with More Than One Table
    8. Isolating Aggregate Query Logic
    9. GROUPING SETS
    10. CUBE and ROLLUP
    11. Thinking About Performance
    12. Summary
  15. Chapter 6: Manipulating Data
    1. Inserting New Rows
    2. Deleting Rows
    3. Updating Existing Rows
    4. Using Transactions
    5. Thinking About Performance
    6. Database Cleanup
    7. Summary
  16. Chapter 7: Understanding T-SQL Programming Logic
    1. Variables
    2. The IF… ELSE Construct
    3. WHILE
    4. Error Handling
    5. Temporary Tables and Table Variables
    6. Thinking About Performance
    7. Summary
  17. Chapter 8: Working with XML
    1. Converting XML into Data Using OPENXML
    2. Retrieving Data as XML Using the FOR XML Clause
    3. XML Data Type
    4. XML Methods
    5. Summary
  18. Chapter 9: Moving Logic to the Database
    1. Tables
    2. Views
    3. User-Defined Functions
    4. Stored Procedures
    5. User-Defined Data Types
    6. Triggers
    7. Thinking About Performance
    8. Database Cleanup
    9. Summary
  19. Chapter 10: Working with Data Types
    1. Large-Value String Data Types (MAX)
    2. Large-Value Binary Data Types
    3. Enhanced Date and Time
    4. HIERARCHYID
    5. Spatial Data Types
    6. Sparse Columns
    7. Summary
  20. Chapter 11: Writing Advanced Queries
    1. Advanced CTE Queries
    2. The OUTPUT Clause
    3. The MERGE Statement
    4. GROUPING SETS
    5. Pivoted Queries
    6. Numbers Table
    7. Database Cleanup
    8. Summary
  21. Chapter 12: Where to Go Next?
    1. Online Resources
    2. Conferences
    3. User Groups
    4. Vendors
    5. Books
    6. Classes
    7. SQL Server Books Online
    8. Practice, Practice, and More Practice
    9. Teach Someone Else
  22. Index