Book description
This thorough, hands-on reference for database developers and administrators delivers expert guidance on sophisticated uses of Transact-SQL (T-SQL)—one of the most familiar and powerful programming languages for SQL Server. Written by a T-SQL guru, this guide focuses on advanced querying techniques and how queries are interpreted and processed by the SQL Server execution engine. You’ll get in-depth coverage of the sophisticated uses of T-SQL, including the differences between logical and physical processing, nesting of queries, and much more. The book explains and compares solutions to database-development problems in both SQL Server 2000 and SQL Server 2005, discussing the new T-SQL programming features added to SQL Server 2005 in detail. Includes extensive code samples, table examples, and logic puzzles to help database developers and administrators understand the intricacies and help promote mastery of T-SQL
Table of contents
- Inside Microsoft® SQL Server™ 2005 T-SQL Querying
- A Note Regarding Supplemental Files
- Foreword
- Preface
- Acknowledgments
- Introduction
-
1. Logical Query Processing
- Logical Query Processing Phases
- Sample Query Based on Customers/Orders Scenario
-
Logical Query Processing Phase Details
- Step 1: Performing a Cartesian Product (Cross Join)
- Step 2: Applying the ON Filter (Join Condition)
- Step 3: Adding Outer Rows
- Step 4: Applying the WHERE Filter
- Step 5: Grouping
- Step 6: Applying the CUBE or ROLLUP Option
- Step 7: Applying the HAVING Filter
- Step 8: Processing the SELECT List
- Step 9: Applying the DISTINCT Clause
- Step 10: Applying the ORDER BY Clause
- Step 11: Applying the TOP Option
- New Logical Processing Phases in SQL Server 2005
- Conclusion
- 2. Physical Query Processing
-
3. Query Tuning
- Sample Data for This Chapter
- Tuning Methodology
- Tools for Query Tuning
-
Index Tuning
- Table and Index Structures
-
Index Access Methods
- Table Scan/Unordered Clustered Index Scan
- Unordered Covering Nonclustered Index Scan
- Ordered Clustered Index Scan
- Ordered Covering Nonclustered Index Scan
- Nonclustered Index Seek + Ordered Partial Scan + Lookups
- Unordered Nonclustered Index Scan + Lookups
- Clustered Index Seek + Ordered Partial Scan
- Covering Nonclustered Index Seek + Ordered Partial Scan
- Index Intersection
- Indexed Views
-
Index Optimization Scale
- Table Scan (Unordered Clustered Index Scan)
- Unordered Covering Nonclustered Index Scan
- Unordered Nonclustered Index Scan + Lookups
- Nonclustered Index Seek + Ordered Partial Scan + Lookups
- Clustered Index Seek + Ordered Partial Scan
- Covering Nonclustered Index Seek + Ordered Partial Scan
- Index Optimization Scale Summary and Analysis
- Fragmentation
- Partitioning
- Preparing Sample Data
- An Examination of Set-Based vs. Iterative/Procedural Approaches, and a Tuning Exercise
- Additional Resources
- Conclusion
-
4. Subqueries, Table Expressions, and Ranking Functions
- Subqueries
- Table Expressions
- Analytical Ranking Functions
- Auxiliary Table of Numbers
- Existing and Missing Ranges (Also Known as Islands and Gaps)
- Conclusion
- 5. Joins and Set Operations
- 6. Aggregating and Pivoting Data
- 7. TOP and APPLY
- 8. Data Modification
- 9. Graphs, Trees, Hierarchies, and Recursive Queries
-
A. Logic Puzzles
-
Puzzles
- Puzzle 1: Medication Tablets
- Puzzle 2: Chocolate Bar
- Puzzle 3: To a T
- Puzzle 4: On the Dot
- Puzzle 5: Rectangles in a Square
- Puzzle 6: Measuring Time by Burning Ropes
- Puzzle 7: Arithmetic Maximum Calculation
- Puzzle 8: Covering a Chessboard with Domino Tiles
- Puzzle 9: The Missing Buck
- Puzzle 10: Flipping Lamp Switches
- Puzzle 11: Cutting a Stick to Make a Triangle
- Puzzle 12: Rectangle Within a Circle
- Puzzle 13: Monty Hall Problem
- Puzzle 14: Piece of Cake
- Puzzle 15: Cards Facing Up
- Puzzle 16: Basic Arithmetic
- Puzzle 17: Self-Replicating Code (Quine)
- Puzzle 18: Hiking a Mountain
- Puzzle 19: Find the Pattern in the Sequence
-
Puzzle Solutions
- Puzzle 1: Medication Tablets
- Puzzle 2: Chocolate Bar
- Puzzle 3: To a T
- Puzzle 4: On the Dot
- Puzzle 5: Rectangles in a Square
- Puzzle 6: Measuring Time by Burning Ropes
- Puzzle 7: Arithmetic Maximum Calculation
- Puzzle 8: Covering a Chessboard with Domino Tiles
- Puzzle 9: The Missing Buck
- Puzzle 10: Alternating Lamp States
- Puzzle 11: Cutting a Stick to Make a Triangle
- Puzzle 12: Rectangle Within a Circle
- Puzzle 13: Monty Hall Problem
- Puzzle 14: Piece of Cake
- Puzzle 15: Cards Facing Up
- Puzzle 16: Basic Arithmetic
- Puzzle 17: Self-Replicating Code (Quine)
- Puzzle 18: Hiking a Mountain
- Puzzle 19: Find the Pattern in the Sequence
- Conclusion
-
Puzzles
- About the Contributors
- Index
- About the Authors
- Copyright
Product information
- Title: Inside Microsoft® SQL Server™ 2005: T-SQL Querying
- Author(s):
- Release date: April 2006
- Publisher(s): Microsoft Press
- ISBN: 9780735623132
You might also like
book
Inside Microsoft® SQL Server® 2008: T-SQL Querying
Tackle the toughest set-based querying and query tuning problems—guided by an author team with in-depth, inside …
book
Microsoft® SQL Server® 2008 T-SQL Fundamentals
Master the foundations of T-SQL with the right balance of conceptual and practical content. Get hands-on …
book
Inside Microsoft® SQL Server® 2008: T-SQL Programming
Get a detailed look at the internal architecture of T-SQL with this comprehensive programming reference. Database …
book
Microsoft® SQL Server 2012 Unleashed
Buy the print version of¿ and get the eBook version for free! eBook version includes chapters …