Get a detailed look at the internal architecture of T-SQL with this comprehensive programming reference. Database developers and administrators get best practices, expert techniques, and code samples to master the intricacies of this programming language—solving complex problems with real-world solutions.
Discover how to:
Work with T-SQL and CLR user-defined functions, stored procedures, and triggers.
Handle transactions, concurrency, and error handling.
Efficiently use temporary objects, including temporary tables, table variables, and table expressions.
Evaluate when to use set-based programming techniques and when to use cursors.
Work with dynamic SQL in an efficient and secure manner.
Treat date- and time-related data in a robust manner.
Develop CLR user-defined types and learn about temporal support in the relational model.
Use XML and XQuery and implement a dynamic schema solution.
Work with spatial data using the new geometry and geography types and spatial indexes.
Track access and changes to data using extended events, SQL Server Audit, change tracking, and change data capture.
Use Service Broker for controlled asynchronous processing in database applications.
All the book’s code samples will be available for download from the companion Web site.
Chapter 1 Views
What Are Views?
ORDER BY in a View
Chapter 2 User-Defined Functions
Some Facts About UDFs
Chapter 3 Stored Procedures
Types of Stored Procedures
The Stored Procedure Interface
Compilations, Recompilations, and Reuse of Execution Plans
Parameterizing Sort Order
CLR Stored Procedures
Chapter 4 Triggers
Chapter 5 Transactions and Concurrency
What Are Transactions?
Locking and Blocking
Chapter 6 Error Handling
Error Handling without the TRY/CATCH Construct
Error Handling with the TRY/CATCH Construct
Chapter 7 Temporary Tables and Table Variables
Chapter 8 Cursors
Dealing with Each Row Individually
Chapter 9 Dynamic SQL
Uses of Dynamic SQL
Chapter 10 Working with Date and Time
Date and Time Data Types
Date and Time Manipulation
Date- and Time-Related Querying Problems
Chapter 11 CLR User-Defined Types
Theoretical Introduction to UDTs
Programming a UDT
Chapter 12 Temporal Support in the Relational Model
Timestamped Predicates and Propositions
Tables with Full Temporal Support
Unpack and Pack
Sixth Normal Form in Use
Chapter 13 XML and XQuery
Converting Relational Data to XML and Vice Versa
The XQuery Language in SQL Server 2008
XML Data Type
Dynamic Relational Schema
Chapter 14 Spatial Data
Introduction to Spatial Data
Basic Spatial Data Concepts
Getting Started with Spatial Data
Spatial Data Validity
Measuring Length and Area
Indexing Spatial Data
Using Spatial Data to Solve Problems
Extending Spatial Support with CLR Routines
Chapter 15 Tracking Access and Changes to Data
Which Technology Do I Use?
Extended Events Implementation
SQL Server Audit Implementation
Change Tracking Implementation
Change Data Capture Implementation
Chapter 16 Service Broker
Routing and Distribution
Where Does Service Broker Fit?
Appendix Companion to CLR Routines
Create the CLRUtilities Database: SQL Server
Development: Visual Studio
Deployment and Testing: Visual Studio and SQL Server
Itzik Ben-Gan is a mentor and cofounder of Solid Quality Mentors. A Microsoft MVP for SQL Server since 1999, Ben-Gan teaches and consults internationally on T-SQL querying, programming, and query tuning. He is the coauthor of Inside Microsoft SQL Server: T-SQL Querying and Inside Microsoft SQL Server:T-SQL Programming. He has written numerous articles for SQL Server Magazine and MSDN®, and speaks at industry events such as Microsoft Tech*Ed, DevWeek, PASS, and SQL Server Connections.
Dejan Sarka is MCT and MCDBA certified and a Microsoft® MVP for SQL Server®. He teaches and consults for Solid Quality Mentors, speaks at TechEd and PASS, and develops OLTP, OLAP, and data mining solutions.
Greg Low is a SQL Server MVP and Microsoft Regional Director. He is based in Melbourne, Australia and is the CEO and Principal Mentor for SQL Down Under. Greg is probably best known for his SQL Down Under podcast.
Roger Wolter is an architect on the Microsoft IT MDM (Master Data Management) project team. He has 30 years of experience in various aspects of the computer industry and has spent the past 10 years as a program manager at Microsoft. His projects at Microsoft include SQLXML, the Soap Toolkit, the SQL Server Service Broker, SQL Server Express, and Master Data Services.Dr.